added check to make sure the db handle is not double-closed (causing segfaults)
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 30 May 2008 02:10:43 +0000 (02:10 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 30 May 2008 02:10:43 +0000 (02:10 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@9734 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/c-apps/oils_cstore.c

index ce5dbdc..8f8820f 100644 (file)
@@ -79,14 +79,15 @@ static int max_flesh_depth = 100;
 void osrfAppChildExit() {
        osrfLogDebug(OSRF_LOG_MARK, "Child is exiting, disconnecting from database...");
 
-       if (writehandle) {
-               dbi_conn_query(writehandle, "ROLLBACK;");
-               dbi_conn_close(writehandle);
-               writehandle = NULL;
-       }
-
-       if (dbhandle)
-               dbi_conn_close(dbhandle);
+    int same = 0;
+    if (writehandle == dbhandle) same = 1;
+    if (writehandle) {
+        dbi_conn_query(writehandle, "ROLLBACK;");
+        dbi_conn_close(writehandle);
+        writehandle = NULL;
+    }
+    if (dbhandle && !same)
+        dbi_conn_close(dbhandle);
 
        // XXX add cleanup of readHandles whenever that gets used