From: Kern Sibbald Date: Mon, 19 Apr 2010 17:01:32 +0000 (+0200) Subject: Fix cancel crash reported by Stephen Thompson X-Git-Tag: Release-5.0.2~22 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a9c37589052dcb08bb7efd342db7646d6966cc6b;p=bacula%2Fbacula Fix cancel crash reported by Stephen Thompson --- diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 857ac31b59..77b3181d7b 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -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); } }