@@ -18,10 +18,12 @@ local dict = util.dict
1818local new_tab = util .new_tab
1919local is_tab = util .is_tab
2020local is_func = util .is_func
21+ local ngx_lua_version = ngx .config .ngx_lua_version
2122
2223local _M = { _VERSION = " 0.4" }
2324local mt = { __index = _M }
2425
26+ local DEFUALT_POOL_BACKLOG = 10
2527local DEFAULT_POOL_SIZE = 30
2628local DEFAULT_IDLE_TIMEOUT = 60 * 1000
2729local DEFAULT_CONN_TIMEOUT = 2 * 1000
@@ -289,7 +291,16 @@ local function connect(self, request)
289291 return true
290292 end
291293
292- return sock :connect (host , port )
294+ if ngx_lua_version < 10014 or self .h2_session_key then
295+ return sock :connect (host , port )
296+ end
297+
298+ local opts = {
299+ pool_size = self .pool_size ,
300+ backlog = DEFUALT_POOL_BACKLOG ,
301+ }
302+
303+ return sock :connect (host , port , opts )
293304end
294305
295306
@@ -526,7 +537,12 @@ local function close(self, keepalive)
526537 end
527538
528539 local idle_timeout = self .conn_idle_timeout
529- return sock :setkeepalive (idle_timeout , self .pool_size )
540+
541+ if self .h2 or ngx_lua_version < 10014 then
542+ return sock :setkeepalive (idle_timeout , self .pool_size )
543+ end
544+
545+ return sock :setkeepalive (idle_timeout )
530546 end
531547
532548 if self .h2 then
0 commit comments