Skip to content

Commit d3d6c58

Browse files
authored
bugfix: connect to unix socket without opts table
The second argument of `sock:connect()` cannot be `nil`. Fixes openresty#187 Bug introduced by 79d2421
1 parent e2db038 commit d3d6c58

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/resty/redis.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,13 @@ function _M.connect(self, host, port_or_opts, opts)
140140
local ok, err
141141

142142
if unix then
143-
ok, err = sock:connect(host, port_or_opts)
144-
opts = port_or_opts
145-
143+
-- second argument of sock:connect() cannot be nil
144+
if port_or_opts ~= nil then
145+
ok, err = sock:connect(host, port_or_opts)
146+
opts = port_or_opts
147+
else
148+
ok, err = sock:connect(host)
149+
end
146150
else
147151
ok, err = sock:connect(host, port_or_opts, opts)
148152
end

0 commit comments

Comments
 (0)