bugfix: mongo disconnect. self.__sock can't be nil because of metatable

This commit is contained in:
Cloud Wu
2014-03-21 11:03:16 +08:00
parent 55f60ab002
commit 1fdce9941b

View File

@@ -97,7 +97,7 @@ local function reply_queue(obj)
while true do while true do
local len_reply = socket.read(sock, 4) local len_reply = socket.read(sock, 4)
if not len_reply then if not len_reply then
if obj.__sock == nil then if not obj.__sock then
return return
end end
sock = reconnect(obj) sock = reconnect(obj)
@@ -105,7 +105,7 @@ local function reply_queue(obj)
local length = driver.length(len_reply) local length = driver.length(len_reply)
local reply = socket.read(sock, length) local reply = socket.read(sock, length)
if not reply then if not reply then
if obj.__sock == nil then if not obj.__sock then
return return
end end
sock = reconnect(obj) sock = reconnect(obj)
@@ -150,7 +150,7 @@ end
function mongo_client:disconnect() function mongo_client:disconnect()
if self.__sock then if self.__sock then
local so = self.__sock local so = self.__sock
self.__sock = nil self.__sock = false
socket.close(so) socket.close(so)
end end
end end