aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_epoll.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-08-14 01:09:55 +0200
committerKim Alvefur <zash@zash.se>2016-08-14 01:09:55 +0200
commit67d21bbcf30ed04c65bdf575dc85056fc8fd57c4 (patch)
tree689e53c2fd4e5aefa3861d1426dcee70f07ab091 /net/server_epoll.lua
parentf4c6b4507a503b3086942893f1222e7c5b50c4fa (diff)
downloadprosody-67d21bbcf30ed04c65bdf575dc85056fc8fd57c4.tar.gz
prosody-67d21bbcf30ed04c65bdf575dc85056fc8fd57c4.zip
net.server_epoll: Wrap calling of ondisconnect listener in additional indirection
Diffstat (limited to 'net/server_epoll.lua')
-rw-r--r--net/server_epoll.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index 7bc93b33..fa79837d 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -155,7 +155,7 @@ function interface:setreadtimeout(t)
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 @@ function interface:starttls(ctx)
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 @@ function interface:tlshandskake()
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 @@ function interface:pausefor(t)
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