Comparison

plugins/mod_proxy65.lua @ 2729:7e0c35713bf5

mod_proxy65: Fix for old-style closing of connections (another source of tracebacks with libevent enabled)
author Matthew Wild <mwild1@gmail.com>
date Mon, 01 Mar 2010 18:07:37 +0000
parent 2320:2ca7445b882a
child 3004:c20b9fe1624b
comparison
equal deleted inserted replaced
2728:3f8d9319d4a3 2729:7e0c35713bf5
89 end 89 end
90 conn:write(string.char(5, 0, 0, 3, sha:len()) .. sha .. string.char(0, 0)); -- VER, REP, RSV, ATYP, BND.ADDR (sha), BND.PORT (2 Byte) 90 conn:write(string.char(5, 0, 0, 3, sha:len()) .. sha .. string.char(0, 0)); -- VER, REP, RSV, ATYP, BND.ADDR (sha), BND.PORT (2 Byte)
91 conn:lock_read(true) 91 conn:lock_read(true)
92 else 92 else
93 module:log("warn", "Neither data transfer nor initial connect of a participator of a transfer.") 93 module:log("warn", "Neither data transfer nor initial connect of a participator of a transfer.")
94 conn.close(); 94 conn:close();
95 end 95 end
96 else 96 else
97 if data ~= nil then 97 if data ~= nil then
98 module:log("warn", "unknown connection with no authentication data -> closing it"); 98 module:log("warn", "unknown connection with no authentication data -> closing it");
99 conn.close(); 99 conn:close();
100 end 100 end
101 end 101 end
102 end 102 end
103 103
104 function connlistener.ondisconnect(conn, err) 104 function connlistener.ondisconnect(conn, err)
105 local session = sessions[conn]; 105 local session = sessions[conn];
106 if session then 106 if session then
107 if session.sha and transfers[session.sha] then 107 if session.sha and transfers[session.sha] then
108 local initiator, target = transfers[session.sha].initiator, transfers[session.sha].target; 108 local initiator, target = transfers[session.sha].initiator, transfers[session.sha].target;
109 if initiator == conn and target ~= nil then 109 if initiator == conn and target ~= nil then
110 target.close(); 110 target:close();
111 elseif target == conn and initiator ~= nil then 111 elseif target == conn and initiator ~= nil then
112 initiator.close(); 112 initiator:close();
113 end 113 end
114 transfers[session.sha] = nil; 114 transfers[session.sha] = nil;
115 end 115 end
116 -- Clean up any session-related stuff here 116 -- Clean up any session-related stuff here
117 sessions[conn] = nil; 117 sessions[conn] = nil;