miyagawa / Starman

Starman is a high-performance preforking Perl PSGI web server
http://search.cpan.org/dist/Starman
Other
287 stars 84 forks source link

detect if the client terminated the connection #105

Open doome opened 10 years ago

doome commented 10 years ago

When a client terminates the underlying TCP connection (even for GET requests), Starman should detect it, and notify the running app of this event, so it can stop processing the request, and wasting resources.

The best way would be a delivered signal (a SIGPIPE maybe?), but if it is easier to implement, the ability to detect EOF in the psgi.input handle would be sufficient. Unfortunately, right now the psgi.input handle is not necessarily the handle of the TCP socket (it is either a null io handle or a Plack::TempBuffer, or something alike), so it is impossible to detect if the peer is still listening to our answer or terminated the connection.

In fact, this should be the part of the PSGI specification. mod_fastcgi uses SIGPIPE for this purpose.