benoitc/gunicorn — pull request #344 by sirkonst (2012-05-14 14:56:59+00:00)
Title: Set timeout for client socket (slow client DoS)

I think need set timeout for client socket when gunicorn processing request, it must be safe from bad slow clients.

Some time I have in log when request processing more then 20-40 minutes (!!!):
```
[gunicorn.error:ERROR] Socket error processing request.
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/gunicorn/workers/async.py", line 38, in handle
self.handle_request(req, client, addr)
File "/usr/lib/pymodules/python2.6/gunicorn/workers/ggevent.py", line 86, in handle_request
super(GeventWorker, self).handle_request(*args)
File "/usr/lib/pymodules/python2.6/gunicorn/workers/async.py", line 79, in handle_request
resp.write(item)
File "/usr/lib/pymodules/python2.6/gunicorn/http/wsgi.py", line 270, in write
util.write(self.sock, arg, self.chunked)
File "/usr/lib/pymodules/python2.6/gunicorn/util.py", line 231, in write
sock.sendall(data)
File "/usr/lib/pymodules/python2.6/gevent/socket.py", line 504, in sendall
data_sent += self.send(_get_memory(data, data_sent), flags)
File "/usr/lib/pymodules/python2.6/gevent/socket.py", line 490, in send
return sock.send(data, flags)
error: [Errno 110] Connection timed out
```

It's my patch. I test only async worker with gevent. Fixs for sync by analogy and not testing.