]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
strengthen JCR reference inc and dec in the FD
authorAlain Spineux <alain@baculasystems.com>
Wed, 12 Jan 2022 14:24:20 +0000 (15:24 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:57 +0000 (13:56 +0200)
- I got a crash at dir->close() while the FD was traced with GDB and
  waiting for too long on the GDB prompt
- this problem should never happens on production system when not using GDB
- Anyway using GDB should not crash the FD

bacula/src/filed/heartbeat.c

index 9fb096598dc14078e03d40b6fe1cf0bf63b9ad95..2ad2f60361f6b6e87c62b72c85512fe44501b996 100644 (file)
@@ -213,6 +213,7 @@ static void *dir_heartbeat_thread(void *arg)
    }
    dir->close();
    jcr->hb_status = -1;         // Mark as stopped
+   free_jcr(jcr);
    return NULL;
 }
 
@@ -222,6 +223,7 @@ static void *dir_heartbeat_thread(void *arg)
 void start_dir_heartbeat(JCR *jcr)
 {
    if (!no_signals && (me->heartbeat_interval > 0)) {
+      jcr->inc_use_count();
       jcr->dir_bsock->set_locking();
       pthread_create(&jcr->heartbeat_id, NULL, dir_heartbeat_thread, (void *)jcr);
    }