]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix cancel crash reported by Stephen Thompson
authorKern Sibbald <kern@sibbald.com>
Mon, 19 Apr 2010 17:01:32 +0000 (19:01 +0200)
committerKern Sibbald <kern@sibbald.com>
Mon, 19 Apr 2010 17:02:18 +0000 (19:02 +0200)
bacula/src/dird/job.c

index 857ac31b5969af5153bf687133a15d50b0738ff6..77b3181d7b916b67a82ef921997caef2406c7003 100644 (file)
@@ -412,7 +412,7 @@ bool cancel_job(UAContext *ua, JCR *jcr)
          fd->close();
          ua->jcr->file_bsock = NULL;
          jcr->file_bsock->set_terminated();
-         if (jcr->my_thread_id) {
+         if (jcr->my_thread_id && !pthread_equal(jcr->my_thread_id, pthread_self())) {
             pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
             Dmsg1(800, "Send kill to jid=%d\n", jcr->JobId);
          }
@@ -451,11 +451,11 @@ bool cancel_job(UAContext *ua, JCR *jcr)
          ua->jcr->store_bsock = NULL;
          jcr->store_bsock->set_timed_out();
          jcr->store_bsock->set_terminated();
-         if (jcr->SD_msg_chan) {
+         if (jcr->SD_msg_chan && !pthread_equal(jcr->SD_msg_chan, pthread_self())) {
             Dmsg2(400, "kill jobid=%d use=%d\n", (int)jcr->JobId, jcr->use_count());
             pthread_kill(jcr->SD_msg_chan, TIMEOUT_SIGNAL);
          }
-         if (jcr->my_thread_id) {
+         if (jcr->my_thread_id && !pthread_equal(jcr->my_thread_id, pthread_self())) {
             pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
          }
       }
@@ -507,11 +507,11 @@ void cancel_storage_daemon_job(JCR *jcr)
       jcr->sd_canceled = true;
       jcr->store_bsock->set_timed_out();
       jcr->store_bsock->set_terminated();
-      if (jcr->SD_msg_chan) {
+      if (jcr->SD_msg_chan && !pthread_equal(jcr->SD_msg_chan, pthread_self())) {
          Dmsg2(400, "kill jobid=%d use=%d\n", (int)jcr->JobId, jcr->use_count());
          pthread_kill(jcr->SD_msg_chan, TIMEOUT_SIGNAL);
       }
-      if (jcr->my_thread_id) {
+      if (jcr->my_thread_id && !pthread_equal(jcr->my_thread_id, pthread_self())) {
          pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
       }
    }