[interchange-cvs] interchange - markj modified 2 files

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Thu Jan 8 12:05:16 UTC 2009


User:      markj
Date:      2009-01-08 12:05:16 GMT
Modified:  code/UserTag child-process.tag
Modified:  lib/Vend Server.pm
Log:
Severs the shared database connection between parent and child when forking an
IC server mid-process to run background ITL. DBI database connections otherwise
continue to share the same database server and the connection is left unusable
for both processes once either one disconnects.

Revision  Changes    Path
1.3                  interchange/code/UserTag/child-process.tag


rev 1.3, prev_rev 1.2
Index: child-process.tag
===================================================================
RCS file: /var/cvs/interchange/code/UserTag/child-process.tag,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- child-process.tag	19 Dec 2008 04:47:42 -0000	1.2
+++ child-process.tag	8 Jan 2009 12:05:16 -0000	1.3
@@ -5,13 +5,13 @@
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.  See the LICENSE file for details.
 # 
-# $Id: child-process.tag,v 1.2 2008-12-19 04:47:42 jon Exp $
+# $Id: child-process.tag,v 1.3 2009-01-08 12:05:16 markj Exp $
 
 UserTag child-process addAttr
 UserTag child-process HasEndTag
 UserTag child-process NoReparse 0
 UserTag child-process Interpolate 0
-UserTag child-process Version $Revision: 1.2 $
+UserTag child-process Version $Revision: 1.3 $
 UserTag child-process Documentation <<EOD
 
 =head1 NAME
@@ -99,6 +99,9 @@
         return;
     }
     else {
+
+        Vend::Server::sever_database();
+
         defined (my $grandkid = fork) or die "Kid cannot fork: $!\n";
         exit if $grandkid;
 



2.96                 interchange/lib/Vend/Server.pm


rev 2.96, prev_rev 2.95
Index: Server.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Server.pm,v
retrieving revision 2.95
retrieving revision 2.96
diff -u -r2.95 -r2.96
--- Server.pm	19 Dec 2008 04:47:42 -0000	2.95
+++ Server.pm	8 Jan 2009 12:05:16 -0000	2.96
@@ -1,6 +1,6 @@
 # Vend::Server - Listen for Interchange CGI requests as a background server
 #
-# $Id: Server.pm,v 2.95 2008-12-19 04:47:42 jon Exp $
+# $Id: Server.pm,v 2.96 2009-01-08 12:05:16 markj Exp $
 #
 # Copyright (C) 2002-2008 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -26,7 +26,7 @@
 package Vend::Server;
 
 use vars qw($VERSION);
-$VERSION = substr(q$Revision: 2.95 $, 10);
+$VERSION = substr(q$Revision: 2.96 $, 10);
 
 use Cwd;
 use POSIX qw(setsid strftime);
@@ -3087,9 +3087,43 @@
     open STDIN, '<', '/dev/null';
     open STDOUT, '>>', '/dev/null';
 
+    return;
+}
+
+sub sever_database {
+    # Because all clients with a common database connection will share
+    # the same db server, we want our severed server (client) not to
+    # destroy the database server when it disconnects.
+    eval {
+        my %d = DBI->installed_drivers;
+        for my $h (values %d) {
+            $_->{InactiveDestroy} = 1
+                for grep { defined } @{ $h->{ChildHandles} };
+        }
+    };
+
+    ::logGlobal(
+        'WARNING - error setting all DBI handles to InactiveDestroy: %s',
+        $@
+    )
+        if ($@);
+
     # Clear any cached DBI handles
     reset_per_fork();
 
+    # Prep new database connections for severed server
+    Vend::Data::open_database(1);
+    while (my ($db, $db_ref) = each %Vend::Database) {
+        next unless
+            ref ($db_ref) eq 'Vend::Table::DBI'
+            &&
+            defined $db_ref->[$Vend::Table::DBI::DBI];
+
+        delete $Vend::Interpolate::Db{$db};
+        $db_ref->close_table;
+        undef $db_ref->[$Vend::Table::DBI::DBI];
+    }
+
     return;
 }
 







More information about the interchange-cvs mailing list