]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/sql.c
Create archivedir
[bacula/bacula] / bacula / src / cats / sql.c
index 5ce1aeb695fbd3754f2d34ffd8eec067fcd12b08..bbee8561b840073c21884939587ba6c6b9c0eead 100644 (file)
@@ -311,37 +311,6 @@ char *db_strerror(B_DB *mdb)
    return mdb->errmsg;
 }
 
-static void update_lock_dbg(B_DB *mdb) 
-{
-#ifdef xxx
-   if (mdb->allow_transactions) { /* batch connection */
-      return;
-   }
-   if (_db_lock_recurse_count && !pthread_equal(_db_lock_threadid, pthread_self())) {
-      Dmsg2(1, "ERROR: not the same threadif %p != %p\n", _db_lock_threadid, pthread_self());
-   }
-   _db_lock_recurse_count++;
-   _db_lock_time = (utime_t) time(NULL);
-   _db_lock_threadid = pthread_self();
-#endif
-}
-
-static void update_unlock_dbg(B_DB *mdb) 
-{
-#ifdef xxx
-   if (mdb->allow_transactions) { /* batch connection */
-      return;
-   }
-   if (!pthread_equal(_db_lock_threadid, pthread_self())) {
-      Dmsg2(1, "ERROR: not the same threadid %p != %p", _db_lock_threadid, pthread_self());
-   }
-   _db_lock_recurse_count--;
-   if (!_db_lock_recurse_count) {
-      memset(&_db_lock_threadid, 0, sizeof(_db_lock_threadid));
-   }
-#endif
-}
-
 /*
  * Lock database, this can be called multiple times by the same
  *   thread without blocking, but must be unlocked the number of
@@ -355,7 +324,6 @@ void _db_lock(const char *file, int line, B_DB *mdb)
       e_msg(file, line, M_FATAL, 0, "rwl_writelock failure. stat=%d: ERR=%s\n",
            errstat, be.bstrerror(errstat));
    }
-   update_lock_dbg(mdb);
 }
 
 /*
@@ -366,7 +334,6 @@ void _db_lock(const char *file, int line, B_DB *mdb)
 void _db_unlock(const char *file, int line, B_DB *mdb)
 {
    int errstat;
-   update_unlock_dbg(mdb);
    if ((errstat=rwl_writeunlock(&mdb->lock)) != 0) {
       berrno be;
       e_msg(file, line, M_FATAL, 0, "rwl_writeunlock failure. stat=%d: ERR=%s\n",
@@ -773,4 +740,28 @@ bool db_open_batch_connexion(JCR *jcr, B_DB *mdb)
    return true;
 }
 
+/*
+ * !!! WARNING !!! Use this function only when bacula is stopped.
+ * ie, after a fatal signal and before exiting the program
+ * Print information about a B_DB object.
+ */
+void _dbg_print_db(JCR *jcr, FILE *fp)
+{
+   B_DB *mdb = jcr->db;
+
+   if (!mdb) {
+      return;
+   }
+
+   fprintf(fp, "B_DB=%p db_name=%s db_user=%s connected=%i\n",
+           mdb, NPRTB(mdb->db_name), NPRTB(mdb->db_user), mdb->connected);
+   fprintf(fp, "\tcmd=\"%s\" changes=%i\n", NPRTB(mdb->cmd), mdb->changes);
+   if (mdb->lock.valid == RWLOCK_VALID) { 
+      fprintf(fp, "\tRWLOCK=%p w_active=%i w_wait=%i\n", &mdb->lock, mdb->lock.w_active, mdb->lock.w_wait);
+#ifndef HAVE_WIN32
+      fprintf(fp, "\t\tthreadid=0x%x mutex=%p\n", (int)mdb->lock.writer_id, &mdb->lock.mutex);
+#endif
+   }
+}
+
 #endif /* HAVE_SQLITE3 || HAVE_MYSQL || HAVE_SQLITE || HAVE_POSTGRESQL*/