Is there a way to have HTTP::Daemon
somehow detect when the client has disconnected (for instance because of a timeout) and thereafter kill itself?
Right now, this is how I wrote my server:
my $response;
try {
local $SIG{ALRM} = sub { die __TIMEOUT__ };
alarm 180;
&process_query;
alarm 0;
$response = new HTTP::Response(200);
}
catch {
if ( $_ eq __TIMEOUT__ ) {
$response = new HTTP::Response(504);
}
else {
$response = new HTTP::Response(500);
}
};
$client->send_response($response);
This just assumes that the client will have given up after 180 seconds, which may or may not be true. I would like to go on processing as long as the client keeps waiting for a response, but not longer.