Code

utils dbi: Guard against multiple calls to dbi_shutdown_r().
authorSebastian Harl <sh@tokkee.org>
Sun, 5 Oct 2014 16:10:09 +0000 (18:10 +0200)
committerSebastian Harl <sh@tokkee.org>
Sun, 5 Oct 2014 17:19:13 +0000 (19:19 +0200)
This should not happen anyway but better be safe than sorry.

src/utils/dbi.c

index 73fc6b77a4e2582b431ac109a1e9147f66535360..261d3b249e5265b089db34f9e4c54e64de34d017 100644 (file)
@@ -379,8 +379,7 @@ sdb_dbi_client_connect(sdb_dbi_client_t *client)
 
        client->conn = dbi_conn_open(driver);
        if (! client->conn) {
-               sdb_log(SDB_LOG_ERR, "dbi: failed to open connection "
-                               "object.");
+               sdb_log(SDB_LOG_ERR, "dbi: failed to open connection object.");
                return -1;
        }
 
@@ -546,7 +545,9 @@ sdb_dbi_client_destroy(sdb_dbi_client_t *client)
                dbi_conn_close(client->conn);
        client->conn = NULL;
 
-       dbi_shutdown_r(client->inst);
+       if (client->inst)
+               dbi_shutdown_r(client->inst);
+       client->inst = NULL;
 
        if (client->options)
                sdb_dbi_options_destroy(client->options);