Skip Menu |

This queue is for tickets about the POE-Component-Server-HTTP CPAN distribution.

Report information
The Basics
Id: 27551
Status: open
Priority: 0/
Queue: POE-Component-Server-HTTP

People
Owner: Nobody in particular
Requestors: DMITRI [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.09
Fixed in: (no value)



Subject: Detecting TCP bind errors.
What happens when a bind failure occurs? To test edge cases in my software, I intentionally specified a port I knew I did not have permissions to. The following was printed to STDERR: Error bind Permission denied (13) happened after Cleanup! Which is generated by this code: sub error { my ($op, $errnum, $errstr, $id) = @_[ARG0..ARG3]; unless ( $_[HEAP]->{c}{$id} ) { warn "Error $op $errstr ($errnum) happened after Cleanup!\n"; return; } The problem with this is that there is no event generated -- the parent session is not notified and thus it will never know that the startup failed. Or am I missing something obvious? Thank you, - Dmitri.
This patch adds a "Failure" handler that gets run in this case. POE::Component::Server::HTTP->new( [....] Failure => sub { # die, or something } ); I hadn't noticed GWYN's patches http://rt.cpan.org/Ticket/Display.html?id=31810 but I don't think they address this particular issue. Correct me if I'm wrong.
--- lib/POE/Component/Server/HTTP.pm 2008-11-25 10:05:24.000000000 -0500 +++ POE-Component-Server-HTTP-0.10/lib/POE/Component/Server/HTTP.pm 2008-11-25 09:58:07.000000000 -0500 @@ -78,6 +78,7 @@ } $self->{Hostname} = hostname() unless($self->{Hostname}); + $self->{Failure} = sub {} unless $self->{Failure}; my $alias = "PoCo::Server::HTTP::[ID]"; my $tcp_alias = $alias . "::TCP"; @@ -99,6 +100,7 @@ $kernel->call($tcp_alias, "shutdown"); $kernel->alias_remove($alias); }, + failure => $self->{Failure}, }, heap => { self => $self } ); @@ -234,6 +236,7 @@ my ($op, $errnum, $errstr, $id) = @_[ARG0..ARG3]; unless ( $_[HEAP]->{c}{$id} ) { warn "Error $op $errstr ($errnum) happened after Cleanup!\n"; + $_[KERNEL]->yield('failure', ( $op, $errnum, $errstr, $id )); return; } my $c = $_[HEAP]->{c}->{$id};