From a355357783f5e1acff48cba47448157ba8f1c076 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Fri, 15 Jun 2012 15:07:07 +0200 Subject: [PATCH] Tweak second part of fix for #1893 --- bacula/src/cats/dbi.c | 4 +++- bacula/src/cats/ingres.c | 4 +++- bacula/src/cats/mysql.c | 4 +++- bacula/src/cats/postgresql.c | 4 +++- bacula/src/cats/sqlite.c | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/bacula/src/cats/dbi.c b/bacula/src/cats/dbi.c index 0dcf2cb026..f48ea0a468 100644 --- a/bacula/src/cats/dbi.c +++ b/bacula/src/cats/dbi.c @@ -347,7 +347,9 @@ void B_DB_DBI::db_close_database(JCR *jcr) P(mutex); m_ref_count--; if (m_ref_count == 0) { - sql_free_result(); + if (m_connected) { + sql_free_result(); + } db_list->remove(this); if (m_connected && m_db_handle) { dbi_shutdown_r(m_instance); diff --git a/bacula/src/cats/ingres.c b/bacula/src/cats/ingres.c index 9199594079..12bab679b8 100755 --- a/bacula/src/cats/ingres.c +++ b/bacula/src/cats/ingres.c @@ -294,7 +294,9 @@ void B_DB_INGRES::db_close_database(JCR *jcr) P(mutex); m_ref_count--; if (m_ref_count == 0) { - sql_free_result(); + if (m_connected) { + sql_free_result(); + } db_list->remove(this); if (m_connected && m_db_handle) { INGdisconnectDB(m_db_handle); diff --git a/bacula/src/cats/mysql.c b/bacula/src/cats/mysql.c index f1be9260e1..a2ed279a2f 100644 --- a/bacula/src/cats/mysql.c +++ b/bacula/src/cats/mysql.c @@ -248,7 +248,9 @@ void B_DB_MYSQL::db_close_database(JCR *jcr) m_ref_count--; Dmsg3(100, "closedb ref=%d connected=%d db=%p\n", m_ref_count, m_connected, m_db_handle); if (m_ref_count == 0) { - sql_free_result(); + if (m_connected) { + sql_free_result(); + } db_list->remove(this); if (m_connected) { Dmsg1(100, "close db=%p\n", m_db_handle); diff --git a/bacula/src/cats/postgresql.c b/bacula/src/cats/postgresql.c index d3ce6e3672..a35083002d 100644 --- a/bacula/src/cats/postgresql.c +++ b/bacula/src/cats/postgresql.c @@ -284,7 +284,9 @@ void B_DB_POSTGRESQL::db_close_database(JCR *jcr) P(mutex); m_ref_count--; if (m_ref_count == 0) { - sql_free_result(); + if (m_connected) { + sql_free_result(); + } db_list->remove(this); if (m_connected && m_db_handle) { PQfinish(m_db_handle); diff --git a/bacula/src/cats/sqlite.c b/bacula/src/cats/sqlite.c index 5957513da7..d3ff4d69d1 100644 --- a/bacula/src/cats/sqlite.c +++ b/bacula/src/cats/sqlite.c @@ -236,7 +236,9 @@ void B_DB_SQLITE::db_close_database(JCR *jcr) P(mutex); m_ref_count--; if (m_ref_count == 0) { - sql_free_result(); + if (m_connected) { + sql_free_result(); + } db_list->remove(this); if (m_connected && m_db_handle) { sqlite3_close(m_db_handle); -- 2.39.5