Comparison

mod_auth_dovecot/auth_dovecot/sasl_dovecot.lib.lua @ 708:d9a4e2f11b07

mod_auth_dovecot: If the connection fails, nuke it so the next attempt causes a reconnect.
author Kim Alvefur <zash@zash.se>
date Sat, 09 Jun 2012 01:47:31 +0200
parent 700:0c130c45b7c1
child 838:c9e2beec4ef6
comparison
equal deleted inserted replaced
707:f987c7b79008 708:d9a4e2f11b07
133 end 133 end
134 module:log("debug", "sending %q", msg:sub(1,-2)); 134 module:log("debug", "sending %q", msg:sub(1,-2));
135 local ok, err = self.conn:send(msg); 135 local ok, err = self.conn:send(msg);
136 if not ok then 136 if not ok then
137 log("error", "Could not write to socket: %s", err); 137 log("error", "Could not write to socket: %s", err);
138 if err == "closed" then
139 conn = nil;
140 end
138 return nil, err; 141 return nil, err;
139 end 142 end
140 return true; 143 return true;
141 end 144 end
142 145
143 function method:recv() 146 function method:recv()
144 --log("debug", "Sent %d bytes to socket", ok); 147 --log("debug", "Sent %d bytes to socket", ok);
145 local line, err = self.conn:receive(); 148 local line, err = self.conn:receive();
146 if not line then 149 if not line then
147 log("error", "Could not read from socket: %s", err); 150 log("error", "Could not read from socket: %s", err);
151 if err == "closed" then
152 conn = nil;
153 end
148 return nil, err; 154 return nil, err;
149 end 155 end
150 module:log("debug", "received %q", line); 156 module:log("debug", "received %q", line);
151 return line; 157 return line;
152 end 158 end