Software /
code /
prosody
Comparison
net/server_epoll.lua @ 8552:1fcefc16a55d
server_epoll: Onconnect should happen before first attempt to write to socket
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 26 Feb 2018 18:31:27 +0100 |
parent | 8542:8c39ec8e6018 |
child | 8555:4f0f5b49bb03 |
comparison
equal
deleted
inserted
replaced
8551:2bd2e94a0496 | 8552:1fcefc16a55d |
---|---|
332 end | 332 end |
333 end | 333 end |
334 | 334 |
335 -- Called when socket is writable | 335 -- Called when socket is writable |
336 function interface:onwritable() | 336 function interface:onwritable() |
337 self:onconnect(); | |
337 local buffer = self.writebuffer; | 338 local buffer = self.writebuffer; |
338 local data = t_concat(buffer); | 339 local data = t_concat(buffer); |
339 local ok, err, partial = self.conn:send(data); | 340 local ok, err, partial = self.conn:send(data); |
340 if ok then | 341 if ok then |
341 self:setflags(nil, false); | 342 self:setflags(nil, false); |
342 for i = #buffer, 1, -1 do | 343 for i = #buffer, 1, -1 do |
343 buffer[i] = nil; | 344 buffer[i] = nil; |
344 end | 345 end |
345 self:setwritetimeout(false); | 346 self:setwritetimeout(false); |
346 self:ondrain(); -- Be aware of writes in ondrain | 347 self:ondrain(); -- Be aware of writes in ondrain |
347 self:onconnect(); | |
348 return; | 348 return; |
349 elseif partial then | 349 elseif partial then |
350 buffer[1] = data:sub(partial+1); | 350 buffer[1] = data:sub(partial+1); |
351 for i = #buffer, 2, -1 do | 351 for i = #buffer, 2, -1 do |
352 buffer[i] = nil; | 352 buffer[i] = nil; |