[FIX] service.server: drop idle connection attempts

Avoid wasting HTTP workers (in prefork server mode)
for pending/idle connections.
HTTP connections that have not sent anything for 500ms
will be dropped.

In particular, wkhtmltopdf uses a connection pool
to load remote resources. It opens more HTTP connections
than necessary and uses a random subset of them, leaving
the other idle.

On a server that has little available workers this
may significantly delay report rendering, and could
even lead to a deadlock.

OPW-667870
This commit is contained in:
Olivier Dony 2016-06-01 18:39:18 +02:00
parent 43cff22950
commit 8245c1d1d8
No known key found for this signature in database
GPG Key ID: CD556E25E8A6D0D4
1 changed files with 1 additions and 0 deletions

View File

@ -773,6 +773,7 @@ class WorkerHTTP(Worker):
""" HTTP Request workers """
def process_request(self, client, addr):
client.setblocking(1)
client.settimeout(0.5)
client.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
# Prevent fd inherientence close_on_exec
flags = fcntl.fcntl(client, fcntl.F_GETFD) | fcntl.FD_CLOEXEC