aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-02-02 23:46:00 +0100
committerKim Alvefur <zash@zash.se>2018-02-02 23:46:00 +0100
commit09f775430279a2e477b3880811432801d0a492a0 (patch)
treef97b0a0a6b6b4f6a4f6db7263750887ee1ff4af2 /net
parentd4ebd958230a6d74b1537941ea454882a59ce39c (diff)
downloadprosody-09f775430279a2e477b3880811432801d0a492a0.tar.gz
prosody-09f775430279a2e477b3880811432801d0a492a0.zip
server_epoll: Rework how socket readyness is detected
Diffstat (limited to 'net')
-rw-r--r--net/server_epoll.lua24
1 files changed, 17 insertions, 7 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index a88aad12..7aad9ede 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -505,9 +505,10 @@ function interface:init()
if self.tls and not self._tls then
return self:starttls();
else
- self.onwriteable = interface.onconnect;
+ self.onwriteable = interface.onfirstwritable;
+ self.onreadable = interface.onfirstreadable;
self:setwritetimeout();
- return self:setflags(false, true);
+ return self:setflags(true, true);
end
end
@@ -537,15 +538,24 @@ end
-- Connected!
function interface:onconnect()
- self.onwriteable = nil;
self:setflags(true, false);
- if not self._connected then
- self._connected = true;
- self:on("connect");
- end
+ self:on("connect");
+end
+
+function interface:onfirstwritable()
+ self.onreadable = nil;
+ self.onwriteable = nil;
+ self:onconnect();
return self:onwriteable();
end
+function interface:onfirstreadable()
+ self.onreadable = nil;
+ self.onwriteable = nil;
+ self:onconnect();
+ return self:onreadable();
+end
+
local function addserver(addr, port, listeners, pattern, tls)
local conn, err = socket.bind(addr, port, cfg.tcp_backlog);
if not conn then return conn, err; end