Subject: | "New request while we still have a request" leads to fatal error |
Date: | Sun, 7 Jul 2013 15:48:33 -0700 |
To: | bug-POEx-HTTP-Server [...] rt.cpan.org |
From: | Dzs Bsd <dzsbsd [...] gmail.com> |
Using POEx::HTTP::Server v0.0901 with perl 5.8.8, the logic behind
pending_push() / pending_next() seems incomplete because reset_req() is not
called after the first response completes. As such, the second response
leads to the server dying: "Responding more then once to a request at
POEx/HTTP/Server.pm line 1048"
The problem can be trivially created by sending two pipelined requests on
the same socket connection:
{ printf "GET /one HTTP/1.1\nHost:server\n\nGET /two
HTTP/1.1\nHost:server\n\n";sleep 1; } | nc server 8080
This demonstration requires a sleep because POEx:HTTP doesn't itself
respond if the client closes its connection first (which looks to be
another bug for you to fix).
The following patch seems to correct an obvious part of the "new request"
problem. The warn "New request while we still have a request" could also be
removed.
--- POEx/HTTP/Server.pm
+++ POEx/HTTP/Server.pm
@@ -1369,6 +1369,7 @@
{
my( $self ) = @_;
return unless $self->{pending} and @{ $self->{pending} };
+ $self->reset_req;
if( $self->{S}{shutdown} or $self->{S}{closing} ) {
$self->D( "We are closing down with pending requests" );
$self->pending_reply;