]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/rwlock.c
Fix reporting jobs from state file + misc
[bacula/bacula] / bacula / src / lib / rwlock.c
index 68adf340b73e453bab412e700b161484a0a2cf92..f6912b519de5eac9632687353607cabc47dd1706 100644 (file)
@@ -236,7 +236,7 @@ int rwl_writelock(brwlock_t *rwl)
       rwl->w_wait--;                 /* we are no longer waiting */
    }
    if (stat == 0) {
-      rwl->w_active = 1;             /* we are running */
+      rwl->w_active++;               /* we are running */
       rwl->writer_id = pthread_self(); /* save writer thread's id */
    }
    pthread_mutex_unlock(&rwl->mutex);
@@ -285,8 +285,11 @@ int rwl_writeunlock(brwlock_t *rwl)
    if ((stat = pthread_mutex_lock(&rwl->mutex)) != 0) {
       return stat;
    }
+   if (rwl->w_active <= 0) {
+      Emsg0(M_ABORT, 0, "rwl_writeunlock called too many times.\n");
+   }
    rwl->w_active--;
-   if (rwl->w_active < 0 || !pthread_equal(pthread_self(), rwl->writer_id)) {
+   if (!pthread_equal(pthread_self(), rwl->writer_id)) {
       Emsg0(M_ABORT, 0, "rwl_writeunlock by non-owner.\n");
    }
    if (rwl->w_active > 0) {
@@ -385,7 +388,7 @@ void *thread_routine(void *arg)
       }
    }
    if (repeats > 0) {
-      Dmsg2(000, "Thread %d found unchanged elements %d times\n",
+      Pmsg2(000, "Thread %d found unchanged elements %d times\n",
         self->thread_num, repeats);
    }
    return NULL;