Author: dpage
Date: 2005-05-20 12:25:24 +0100 (Fri, 20 May 2005)
New Revision: 4226

Modified:
   trunk/pgadmin3/xtra/pgagent/connection.cpp
Log:
Only clear down connections that are not in use.

Modified: trunk/pgadmin3/xtra/pgagent/connection.cpp
===================================================================
--- trunk/pgadmin3/xtra/pgagent/connection.cpp  2005-05-20 09:29:33 UTC (rev 
4225)
+++ trunk/pgadmin3/xtra/pgagent/connection.cpp  2005-05-20 11:25:24 UTC (rev 
4226)
@@ -142,7 +142,7 @@
        if (all)
                LogMessage("Clearing all connections", LOG_DEBUG);
        else
-               LogMessage("Clearing all connections except the primary", 
LOG_DEBUG);
+               LogMessage("Clearing inactive connections", LOG_DEBUG);
 
        DBconn *thisConn=primaryConn, *deleteConn;
 
@@ -151,12 +151,27 @@
                thisConn = thisConn->next;
 
        // Delete connections as required
+       // If a connection is not in use, delete it, and reset the next and 
previous
+       // pointers appropriately. If it is in use, don't touch it.
        while (thisConn->prev != 0)
        {
-               deleteConn = thisConn;
-               thisConn = deleteConn->prev;
-               delete deleteConn;
-               thisConn->next = 0;
+               if ((!thisConn->inUse) || all)
+               {
+                       deleteConn = thisConn;
+
+                       thisConn = deleteConn->prev;
+                       
+                       thisConn->next = deleteConn->next;
+                       
+                       if (deleteConn->next)
+                               deleteConn->next->prev = deleteConn->prev;
+                       
+                       delete deleteConn;
+               }
+               else
+               {
+                       thisConn = thisConn->prev;
+               }
        }
 
        if (all)


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to