unbit/uwsgi — pull request #614 by trawick (2014-05-01 18:51:50+00:00)
Title: Implement lingering close for TCP sockets (FastCGI protocol only).

Similar to
nginx as a server
httpd as a server
flup as a FastCGI server
Open Market FastCGI programming library (server)
etc. (not just HTTP or SCGI or FastCGI)

See new comments for considerations for an efficient implementation.

It is nice that this will eat all input (subject to timeout), which
helps when the application sends an error message while the client
is still writing the request body. (The client gets to see the
error message.) But typically the server-side of the socket isn't
willing to read arbitrary amounts of data, so that feature would
be lost when the client is still writing body for a while.

One testcase I used:
mod_proxy_fcgi connecting over a local LAN to uWSGI and simple WSGI app.
ab -n 100 -c 20, post 67K and get back a 67K response
After increasing the uWSGI socket timeout, I had about 12 failures when using git uwsgi from today -- all ECONNRESET errors when mod_proxy_fcgi tried to read response.

With this patch I don't see any errors.