aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-09-29 15:41:01 +0200
committerKim Alvefur <zash@zash.se>2019-09-29 15:41:01 +0200
commit79b375cb53b2e160d18309c6f88b9fa70a88d2e5 (patch)
tree37f1f06555a0279ae5e34c208af5e5e7344cb33c /net
parent5eea3358fd7f8ca8b0edb36769b393bb0f1423ca (diff)
downloadprosody-79b375cb53b2e160d18309c6f88b9fa70a88d2e5.tar.gz
prosody-79b375cb53b2e160d18309c6f88b9fa70a88d2e5.zip
net.server_epoll: Fix link function to not replace listeners
mod_proxy65 calls link twice, once for each direction. This would overwrite the listeners with one that has the previous listeners as metatable.__index, but none of the others. This takes advantage of 94c584d67533 to improve this.
Diffstat (limited to 'net')
-rw-r--r--net/server_epoll.lua14
1 files changed, 5 insertions, 9 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index c2eb7b1c..d2964888 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -793,17 +793,13 @@ end;
-- Dump all data from one connection into another
local function link(from, to, read_size)
from:debug("Linking to %s", to.id);
- from.listeners = setmetatable({
- onincoming = function (_, data)
- from:pause();
+ function from:onincoming(data)
+ self:pause();
to:write(data);
- end,
- }, {__index=from.listeners});
- to.listeners = setmetatable({
- ondrain = function ()
+ end
+ function to:ondrain()
from:resume();
- end,
- }, {__index=to.listeners});
+ end
from:set_mode(read_size);
from:set(true, nil);
to:set(nil, true);