More tweaking to async code
authorGreg Sabino Mullane <greg@endpoint.com>
Fri, 2 May 2014 23:34:44 +0000 (19:34 -0400)
committerGreg Sabino Mullane <greg@endpoint.com>
Fri, 2 May 2014 23:34:44 +0000 (19:34 -0400)
Bucardo.pm

index aa834ac333e9a257f84abf77e219105fdde3d0fc..6f110b22c0cf75889902933cb9bc08aadd9360e9 100644 (file)
@@ -2305,21 +2305,22 @@ sub start_kid {
             ## Is this still around?
             if (!$dbh->ping) {
                 $self->glog("Ping failed for database $dbname", LOG_TERSE);
+                ## We'll assume no disconnect is necessary - but we'll undef it below just in case
             }
             else {
-                ## If in the middle of an async, clear it out
-                if ($x->{async_active}) {
-                    $dbh->pg_cancel();
-                    $x->{async_active} = 0;
-                }
-
+                ## Rollback, finish all statement handles, and disconnect
                 $dbh->rollback();
-
                 $self->glog("Disconnecting from database $dbname", LOG_DEBUG);
                 $_->finish for values %{ $dbh->{CachedKids} };
                 $dbh->disconnect();
             }
 
+            ## Make sure we don't think we are still in the middle of an async query
+            $x->{async_active} = 0;
+
+            ## Make sure we never access this connection again
+            undef $dbh;
+
             ## Clear out the entry from the dbrun table
             $sth = $sth{dbrun_delete};
             $sth->execute($syncname, $dbname);