Skip to content

Commit

Permalink
add handle net error when connect to server
Browse files Browse the repository at this point in the history
  • Loading branch information
azurewang committed Apr 20, 2013
1 parent 3d8b145 commit 19bc847
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/resty/postgres.lua
Expand Up @@ -111,12 +111,18 @@ function _parse_error_packet(packet)
msg = {}
while true do
flg = string.sub(packet, pos, pos)
if not flg then
return nil, "parse error packet fail"
end
pos = pos + 1
if flg == '\0' then
break
end
-- all flg S/C/M/P/F/L/R
value, pos = _from_cstring(packet, pos)
if not value then
return nil, "parse error packet fail"
end
msg[flg] = value
end
return msg
Expand Down Expand Up @@ -243,6 +249,9 @@ function connect(self, opts)
end
while true do
packet, typ, err = _recv_packet(self)
if not packet then
return nil, "read packet error:" .. err
end
-- env
if typ == 'S' then
local pos = 1
Expand Down

0 comments on commit 19bc847

Please sign in to comment.