[Jifty-commit] r6927 - in jifty/trunk/lib: . Jifty Jifty/Server/Prefork
Jifty commits
jifty-commit at lists.jifty.org
Thu Apr 30 23:16:50 EDT 2009
Author: alexmv
Date: Thu Apr 30 23:16:50 2009
New Revision: 6927
Modified:
jifty/trunk/lib/Jifty.pm
jifty/trunk/lib/Jifty/Server.pm
jifty/trunk/lib/Jifty/Server/Fork/NetServer.pm
jifty/trunk/lib/Jifty/Server/Prefork/NetServer.pm
Log:
Close Net::Server client sockets on background
HTTP::Server::Simple, when Net::Server implementations are used, does
not store away the created Net::Server subclasses. This means that it
is not possible to find and close the client connections after a
fork(). We amend the Net::Server::Fork and Net::Server::PreFork
classes to store themselves on the Jifty::Server object, so we can
close client connections as need be later.
Modified: jifty/trunk/lib/Jifty.pm
==============================================================================
--- jifty/trunk/lib/Jifty.pm (original)
+++ jifty/trunk/lib/Jifty.pm Thu Apr 30 23:16:50 2009
@@ -525,8 +525,8 @@
=head2 background SUB
-Forks a background process, and ensures that database connections are
-not shared with the parent process.
+Forks a background process, and ensures that database connections and
+sockets are not shared with the parent process.
=cut
@@ -538,6 +538,7 @@
} else {
close STDOUT;
close STDIN;
+ $Jifty::SERVER->close_sockets if $Jifty::SERVER;
Jifty->setup_database_connection();
$sub->();
exit;
Modified: jifty/trunk/lib/Jifty/Server.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Server.pm (original)
+++ jifty/trunk/lib/Jifty/Server.pm Thu Apr 30 23:16:50 2009
@@ -149,5 +149,22 @@
$self->SUPER::restart;
}
+=head2 close_client_sockets
+
+Closes all active client connections.
+
+=cut
+
+sub close_client_sockets {
+ my $self = shift;
+ close STDOUT;
+ close STDIN;
+ if ($self->{net_server}) {
+ close $self->{net_server}{server}{client};
+ } else {
+ close $self->{_stdio_handle};
+ }
+}
+
1;
Modified: jifty/trunk/lib/Jifty/Server/Fork/NetServer.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Server/Fork/NetServer.pm (original)
+++ jifty/trunk/lib/Jifty/Server/Fork/NetServer.pm Thu Apr 30 23:16:50 2009
@@ -8,6 +8,19 @@
=head1 METHODS
+=head2 new
+
+Store the created L<Net::Server::Fork> object away after creating it.
+
+=cut
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new(@_);
+ $Jifty::SERVER->{net_server} = $self;
+ return $self;
+}
+
=head2 post_accept_hook
After forking every connection, resetup the database connections so we
Modified: jifty/trunk/lib/Jifty/Server/Prefork/NetServer.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Server/Prefork/NetServer.pm (original)
+++ jifty/trunk/lib/Jifty/Server/Prefork/NetServer.pm Thu Apr 30 23:16:50 2009
@@ -8,6 +8,19 @@
=head1 METHODS
+=head2 new
+
+Store the created L<Net::Server::Fork> object away after creating it.
+
+=cut
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new(@_);
+ $Jifty::SERVER->{net_server} = $self;
+ return $self;
+}
+
=head2 child_init_hook
Sets up the database connection when spawning a new child
More information about the Jifty-commit
mailing list