return mdb->errmsg;
}
-static void update_lock_dbg(B_DB *mdb)
-{
- 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();
-}
-
-static void update_unlock_dbg(B_DB *mdb)
-{
- 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));
- }
-}
-
/*
* Lock database, this can be called multiple times by the same
* thread without blocking, but must be unlocked the number of
e_msg(file, line, M_FATAL, 0, "rwl_writelock failure. stat=%d: ERR=%s\n",
errstat, be.bstrerror(errstat));
}
- update_lock_dbg(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",
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*/