Skip Menu |

This queue is for tickets about the Net-Server CPAN distribution.

Report information
The Basics
Id: 55485
Status: resolved
Priority: 0/
Queue: Net-Server

People
Owner: Nobody in particular
Requestors: dkg [...] fifthhorseman.net
Cc:
AdminCc:

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



Subject: other_child_died_hook() for Net::Server [PATCH]
Date: Thu, 11 Mar 2010 17:04:49 -0500
To: Paul Seamons <paul [...] seamons.com>, Rob Brown <bbb [...] cpan.org>, bug-Net-Server [...] rt.cpan.org
From: Daniel Kahn Gillmor <dkg [...] fifthhorseman.net>
Net::Server takes control of signal handling and child process cleanup; this makes it difficult to tell when a child process terminates if that child process was not started by Net::Server itself. The attached patch implements other_child_died_hook(), which is called when a non-managed process dies. If Net::Server notices another child process dying that it did not start, it will fire this hook with the PID of the terminated process as its argument. The patch should apply to 0.97 of Net::Server. Thanks for Net::Server. It's a very useful perl module! --dkg
--- /usr/share/perl5/Net/Server.pm 2007-07-25 12:21:14.000000000 -0400 +++ Net/Server.pm 2010-03-11 16:40:09.000000000 -0500 @@ -1441,6 +1441,9 @@ $self->process_args( $self->{server}->{conf_file_args}, $template ); } +### User-customizable hook to handle child dying +sub other_child_died_hook {} + ### remove a child from the children hash. Not to be called by user. ### if UNIX sockets are in use the socket is removed from the select object. sub delete_child { @@ -1449,7 +1452,10 @@ my $prop = $self->{server}; ### don't remove children that don't belong to me (Christian Mock, Luca Filipozzi) - return unless exists $prop->{children}->{$pid}; + if (! exists $prop->{children}->{$pid}) { + $self->other_child_died_hook($pid); + return; + } ### prefork server check to clear child communication if( $prop->{child_communication} ){ --- /usr/share/perl5/Net/Server.pod 2007-07-25 12:19:40.000000000 -0400 +++ Net/Server.pod 2010-03-11 16:45:09.000000000 -0500 @@ -1118,6 +1118,15 @@ and hooks that will run during the run_client_connection have finished and the client connection has already been closed. +=item C<$self-E<gt>other_child_died_hook($pid)> + +Net::Server takes control of signal handling and child process +cleanup; this makes it difficult to tell when a child process +terminates if that child process was not started by Net::Server +itself. If Net::Server notices another child process dying that it +did not start, it will fire this hook with the PID of the terminated +process. + =item C<$self-E<gt>pre_server_close_hook()> This hook occurs before the server begins shutting down.
Download signature.asc
application/pgp-signature 891b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #55485] AutoReply: other_child_died_hook() for Net::Server [PATCH]
Date: Thu, 11 Mar 2010 20:42:50 -0500
To: bug-Net-Server [...] rt.cpan.org
From: Daniel Kahn Gillmor <dkg [...] fifthhorseman.net>
One workaround for RT #55485 for users of current versions of Net::Server is to override delete_child() with something like this: sub delete_child { my $self = shift; my $pid = shift; # do your own stuff here... # invoke the parent class' implementation $self->SUPER::delete_child($pid, @_); } The trouble with this workaround is that delete_child isn't a documented interface, so i don't know that we have a guarantee that it will stick around in future versions of Net::Server as a stable thing to override. So perhaps another way to resolve #55485 would be to explicitly document delete_child() and commit to it as a maintained interface. hope this is helpful, --dkg
Download signature.asc
application/pgp-signature 891b

Message body not shown because it is not plain text.

This patch has been applied in 0.99. Thanks for the patch.