Software /
code /
prosody
Comparison
net/server_epoll.lua @ 11922:28f5c8061dad
net.server_epoll: Fix streaming downloads (thanks Menel)
ff4e34c448a4 broke the way net.http.server streams downloads from disk
because it made writes from the ondrain callback no longer reset the
want-write flag, causing the download to halt.
Writes from the predrain handler still must not trigger anything but
additions to the buffer, since it is about to do all the socket writing
already.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 19 Nov 2021 15:45:01 +0100 |
parent | 11920:ff4e34c448a4 |
child | 11972:520ce76440ad |
comparison
equal
deleted
inserted
replaced
11921:89aef37fca54 | 11922:28f5c8061dad |
---|---|
511 buffer[i] = nil; | 511 buffer[i] = nil; |
512 end | 512 end |
513 else | 513 else |
514 self.writebuffer = nil; | 514 self.writebuffer = nil; |
515 end | 515 end |
516 self._writing = nil; | |
516 self:setwritetimeout(false); | 517 self:setwritetimeout(false); |
517 self:ondrain(); -- Be aware of writes in ondrain | 518 self:ondrain(); -- Be aware of writes in ondrain |
518 self._writing = nil; | |
519 return ok; | 519 return ok; |
520 elseif partial then | 520 elseif partial then |
521 self:debug("Sent %d out of %d buffered bytes", partial, #data); | 521 self:debug("Sent %d out of %d buffered bytes", partial, #data); |
522 if cfg.keep_buffers and type(buffer) == "table" then | 522 if cfg.keep_buffers and type(buffer) == "table" then |
523 buffer[1] = data:sub(partial+1); | 523 buffer[1] = data:sub(partial+1); |