[Jifty-commit] r6955 - in jifty/trunk/lib/Jifty/Server: Prefork

Jifty commits jifty-commit at lists.jifty.org
Thu May 7 18:49:52 EDT 2009


Author: alexmv
Date: Thu May  7 18:49:52 2009
New Revision: 6955

Modified:
   jifty/trunk/lib/Jifty/Server/Fork/NetServer.pm
   jifty/trunk/lib/Jifty/Server/Prefork/NetServer.pm

Log:
In forking servers, disconnect the database before stalling on accept

In forking servers, the main server process never accesses the
database, so it does not need to hold a database connection open.
After working, ither it or its children need to set InactiveDestroy,
or it needs to not have a connection at all.  Since a connection is
not needed, we choose the latter.

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 May  7 18:49:52 2009
@@ -21,15 +21,26 @@
     return $self;
 }
 
+=head2 pre_loop_hook
+
+Tear down the database connection before falling into the accept loop,
+so that there is no shared database connection for children to
+inherit.
+
+=cut
+
+sub pre_loop_hook {
+    Jifty->handle(undef);
+}
+
 =head2 post_accept_hook
 
-After forking every connection, resetup the database connections so we
-don't share them with our parent.
+After forking every connection, resetup the database connections.
 
 =cut
 
 sub post_accept_hook {
-    Jifty->setup_database_connection();
+    Jifty->setup_database_connection;
 }
 
 =head2 log

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 May  7 18:49:52 2009
@@ -21,14 +21,26 @@
     return $self;
 }
 
+=head2 pre_loop_hook
+
+Tear down the database connection before falling into the accept loop,
+so that there is no shared database connection for children to
+inherit.
+
+=cut
+
+sub pre_loop_hook {
+    Jifty->handle(undef);
+}
+
 =head2 child_init_hook
 
-Sets up the database connection when spawning a new child
+Sets up the database connection when spawning a new child.
 
 =cut
 
 sub child_init_hook {
-    Jifty->setup_database_connection();
+    Jifty->setup_database_connection;
 }
 
 =head2 log


More information about the Jifty-commit mailing list