If the client disconnected when the application is returning a big
response, uWSGI will produce a lot of log messages and takes 100% cpu
usage for a period of time.

This is the sample application:

def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/plain')])
    for i in range(1000000):
        yield 'X' * 100 + '\n'

when the client disconnected, uWSGI produces a lot of log messages:

send(): Broken pipe [plugins/http/http.c line 810]
Tue Mar 27 11:26:42 2012 - write(): Connection reset by peer
[proto/uwsgi.c line 138] during GET / (10.5.1.238)
SIGPIPE: writing to a closed pipe/socket/fd (probably the client
disconnected) on request / (ip 10.5.1.238) !!!
Tue Mar 27 11:26:42 2012 - write(): Broken pipe [proto/uwsgi.c line
138] during GET / (10.5.1.238)
SIGPIPE: writing to a closed pipe/socket/fd (probably the client
disconnected) on request / (ip 10.5.1.238) !!!
Tue Mar 27 11:26:42 2012 - write(): Broken pipe [proto/uwsgi.c line
138] during GET / (10.5.1.238)
SIGPIPE: writing to a closed pipe/socket/fd (probably the client
disconnected) on request / (ip 10.5.1.238) !!!
Tue Mar 27 11:26:42 2012 - write(): Broken pipe [proto/uwsgi.c line
138] during GET / (10.5.1.238)
SIGPIPE: writing to a closed pipe/socket/fd (probably the client
disconnected) on request / (ip 10.5.1.238) !!!
Tue Mar 27 11:26:42 2012 - write(): Broken pipe [proto/uwsgi.c line
138] during GET / (10.5.1.238)
SIGPIPE: writing to a closed pipe/socket/fd (probably the client
disconnected) on request / (ip 10.5.1.238) !!!
Tue Mar 27 11:26:42 2012 - write(): Broken pipe [proto/uwsgi.c line
138] during GET / (10.5.1.238)
SIGPIPE: writing to a closed pipe/socket/fd (probably the client
disconnected) on request / (ip 10.5.1.238) !!!
Tue Mar 27 11:26:42 2012 - write(): Broken pipe [proto/uwsgi.c line
138] during GET / (10.5.1.238)
SIGPIPE: writing to a closed pipe/socket/fd (probably the client
disconnected) on request / (ip 10.5.1.238) !!!
Tue Mar 27 11:26:42 2012 - write(): Broken pipe [proto/uwsgi.c line
138] during GET / (10.5.1.238)
...

Attachment is the patch. It will check the return value of
uwsgi_proto_uwsgi_write() and stop if necessary.

Attachment: fix-client-disconnected.patch
Description: Binary data

_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to