News for hackers. Stuff that matters.
Re:The curious case of slow downloads by Dylan16807 on Wednesday May 04, 2016 @08:50AM (#11627929)
The TCP layer is already perfectly capable of detecting if a connection has failed. NGINX wanted to do something extra, and did it incorrectly.
Re:The curious case of slow downloads by scurvy on Wednesday May 04, 2016 @09:43AM (#11628241)
nginx is also resetting the connection instead of closing it. That's also a bug (separately). The use of a TCP reset here violates RFC and Postel's robustness maxim. Be liberal on what you accept and be conservative in what you send.
Re:The curious case of slow downloads by masklinn on Wednesday May 04, 2016 @08:56AM (#11627960)
> NGINX wanted to do something extra, and did it incorrectly.

Having a timeout on a poll (or select) is not "something extra". it's something entirely normal and necessary for any non-trivial software, especially public-facing ones.

Re:The curious case of slow downloads by Dylan16807 on Wednesday May 04, 2016 @09:07AM (#11628013)
What? They wanted a timeout on how long it takes X bytes to send on an active TCP connection. That has nothing to do with poll/select timeouts.
Re:The curious case of slow downloads by masklinn on Wednesday May 04, 2016 @09:31AM (#11628161)
> What? They wanted a timeout on how long it takes X bytes to send on an active TCP connection. That has nothing to do with poll/select timeouts.

nginx called send(file), then polled the socket for write with the timeout, closing the connection if the timeout was hit. It has everything to do with poll/select timeouts, and especially with Linux letting poll hit timeouts when waiting on effectively writable sockets.

Re:The curious case of slow downloads by Dylan16807 on Wednesday May 04, 2016 @09:44AM (#11628253)
> writable sockets

The goal of NGINX here is not to measure whether a socket can consume any data whatsoever. A connection that consumes 1 byte every 15 seconds is still considered stalled, and should be killed. Using the time between sendfile invocations is not the goal, it's a means toward implementing a minimum rate, and they implemented a minimum rate the wrong way. It's an X Y problem and that's not the kernel's fault.

Re:The curious case of slow downloads by zzzcpan on Wednesday May 04, 2016 @09:56AM (#11628348)
The problem is a fundamental one. Nginx, like many other event loop implementations of servers, presumes that kernel code behaves consistently, precisely and correctly, instead of treating it like a black box, that sometimes lies about things or behaves completely incorrectly, it's not the first time this happened. Any correct event loop implementation should take reported poll events under advisement only and try to schedule reads and writes independently from that.
Re:The curious case of slow downloads by pjc50 on Wednesday May 04, 2016 @09:29AM (#11628148)
.. and the correct way to do this is SO_SNDTIMEO.
Re:The curious case of slow downloads by masklinn on Wednesday May 04, 2016 @09:33AM (#11628172)
That's for blocking IO, it doesn't work on evented IO:

> [SO_RCVTIMEO and SO_SNDTIMEO] only have effect for system calls that perform socket I/O (e.g., read(2), recvmsg(2), send(2), sendmsg(2)); timeouts have no effect for select(2), poll(2), epoll_wait(2), and so on.

And from my understanding would have the same effect as a timeout on select/poll, so it's not the correct way to do anything.