Comparison

net/server_epoll.lua @ 10284:cd669975031b

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.
author Kim Alvefur <zash@zash.se>
date Sun, 29 Sep 2019 15:41:01 +0200
parent 10283:dff360d00dfa
child 10285:bcf61e22f841
comparison
equal deleted inserted replaced
10283:dff360d00dfa 10284:cd669975031b
791 end; 791 end;
792 792
793 -- Dump all data from one connection into another 793 -- Dump all data from one connection into another
794 local function link(from, to, read_size) 794 local function link(from, to, read_size)
795 from:debug("Linking to %s", to.id); 795 from:debug("Linking to %s", to.id);
796 from.listeners = setmetatable({ 796 function from:onincoming(data)
797 onincoming = function (_, data) 797 self:pause();
798 from:pause();
799 to:write(data); 798 to:write(data);
800 end, 799 end
801 }, {__index=from.listeners}); 800 function to:ondrain()
802 to.listeners = setmetatable({
803 ondrain = function ()
804 from:resume(); 801 from:resume();
805 end, 802 end
806 }, {__index=to.listeners});
807 from:set_mode(read_size); 803 from:set_mode(read_size);
808 from:set(true, nil); 804 from:set(true, nil);
809 to:set(nil, true); 805 to:set(nil, true);
810 end 806 end
811 807