Software /
code /
prosody
Diff
net/server_epoll.lua @ 7563:71dc0d89a9b8
net.server_epoll: Wrap calling of ondisconnect listener in additional indirection
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 14 Aug 2016 01:09:55 +0200 |
parent | 7560:785fa1138293 |
child | 7564:f95ffd24e042 |
line wrap: on
line diff
--- a/net/server_epoll.lua Fri Aug 12 01:38:47 2016 +0200 +++ b/net/server_epoll.lua Sun Aug 14 01:09:55 2016 +0200 @@ -155,7 +155,7 @@ if self:onreadtimeout() then return cfg.read_timeout; else - self.listeners.ondisconnect(self, "read timeout"); + self:ondisconnect("read timeout"); self:destroy(); end end); @@ -330,7 +330,7 @@ self:setflags(false, false); local conn, err = luasec.wrap(self.conn, ctx or self.tls); if not conn then - self.listeners.ondisconnect(self, err); + self:ondisconnect(err); self:destroy(); end conn:settimeout(0); @@ -365,7 +365,7 @@ self:setreadtimeout(false); self:setwritetimeout(cfg.handshake_timeout); else - self.listeners.ondisconnect(self, err); + self:ondisconnect(err); self:destroy(); end end @@ -430,9 +430,17 @@ end); end +function interface:ondisconnect(err) + if self.listeners.ondisconnect then + self.listeners.ondisconnect(self, err); + end +end + function interface:onconnect() self.onwriteable = nil; - self.listeners.onconnect(self); + if self.listeners.onconnect then + self.listeners.onconnect(self); + end self:setflags(true); return self:onwriteable(); end