]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix Bacula to work with newer Windows pthreads library
authorKern Sibbald <kern@sibbald.com>
Mon, 9 Jun 2014 15:39:26 +0000 (17:39 +0200)
committerKern Sibbald <kern@sibbald.com>
Mon, 9 Jun 2014 15:39:26 +0000 (17:39 +0200)
bacula/src/dird/backup.c
bacula/src/dird/job.c
bacula/src/dird/mac.c
bacula/src/dird/msgchan.c
bacula/src/dird/restore.c
bacula/src/dird/vbackup.c
bacula/src/jcr.h

index 6492e1e34eb244d4417b776f2b63b660b9ddd628..25728b2c98df282ae3be3c728c269b719ab504c9 100644 (file)
@@ -783,7 +783,7 @@ void backup_cleanup(JCR *jcr, int TermCode)
          msg_type = M_ERROR;          /* Generate error message */
          if (jcr->store_bsock) {
             jcr->store_bsock->signal(BNET_TERMINATE);
-            if (jcr->SD_msg_chan) {
+            if (jcr->SD_msg_chan_started) {
                pthread_cancel(jcr->SD_msg_chan);
             }
          }
@@ -792,7 +792,7 @@ void backup_cleanup(JCR *jcr, int TermCode)
          term_msg = _("Backup Canceled");
          if (jcr->store_bsock) {
             jcr->store_bsock->signal(BNET_TERMINATE);
-            if (jcr->SD_msg_chan) {
+            if (jcr->SD_msg_chan_started) {
                pthread_cancel(jcr->SD_msg_chan);
             }
          }
index 96f4ead6e2cb3519a8c947b6b9313227f32e7677..fa667d40dbab3c59b0104c7220bc37e9ae297d5e 100644 (file)
@@ -358,7 +358,7 @@ void sd_msg_thread_send_signal(JCR *jcr, int sig)
 {
    jcr->lock();
    if (  !jcr->sd_msg_thread_done
-       && jcr->SD_msg_chan
+       && jcr->SD_msg_chan_started
        && !pthread_equal(jcr->SD_msg_chan, pthread_self()))
    {
       Dmsg1(800, "Send kill to SD msg chan jid=%d\n", jcr->JobId);
index 49de6df01ebddc57ad0ae5ee520daea14d1b2763..64830118394223cd47dfa811d4d74b4c37c4a264 100644 (file)
@@ -739,13 +739,13 @@ void mac_cleanup(JCR *jcr, int TermCode, int writeTermCode)
          msg_type = M_ERROR;          /* Generate error message */
          if (jcr->store_bsock) {
             jcr->store_bsock->signal(BNET_TERMINATE);
-            if (jcr->SD_msg_chan) {
+            if (jcr->SD_msg_chan_started) {
                pthread_cancel(jcr->SD_msg_chan);
             }
          }
          if (wjcr->store_bsock) {
             wjcr->store_bsock->signal(BNET_TERMINATE);
-            if (wjcr->SD_msg_chan) {
+            if (wjcr->SD_msg_chan_started) {
                pthread_cancel(wjcr->SD_msg_chan);
             }
          }
@@ -754,13 +754,13 @@ void mac_cleanup(JCR *jcr, int TermCode, int writeTermCode)
          term_msg = _("%s Canceled");
          if (jcr->store_bsock) {
             jcr->store_bsock->signal(BNET_TERMINATE);
-            if (jcr->SD_msg_chan) {
+            if (jcr->SD_msg_chan_started) {
                pthread_cancel(jcr->SD_msg_chan);
             }
          }
          if (wjcr->store_bsock) {
             wjcr->store_bsock->signal(BNET_TERMINATE);
-            if (wjcr->SD_msg_chan) {
+            if (wjcr->SD_msg_chan_started) {
                pthread_cancel(wjcr->SD_msg_chan);
             }
          }
index c012e2cee532921511c6661eac835db2c70de14b..7ea6359152285d76f74f8b0c221aa74b17777cd1 100644 (file)
@@ -368,14 +368,14 @@ bool start_storage_daemon_message_thread(JCR *jcr)
 
    jcr->inc_use_count();              /* mark in use by msg thread */
    jcr->sd_msg_thread_done = false;
-   jcr->SD_msg_chan = 0;
+   jcr->SD_msg_chan_started = false;
    Dmsg0(150, "Start SD msg_thread.\n");
    if ((status=pthread_create(&thid, NULL, msg_thread, (void *)jcr)) != 0) {
       berrno be;
       Jmsg1(jcr, M_ABORT, 0, _("Cannot create message thread: %s\n"), be.bstrerror(status));
    }
    /* Wait for thread to start */
-   while (jcr->SD_msg_chan == 0) {
+   while (!jcr->SD_msg_chan_started) {
       bmicrosleep(0, 50);
       if (job_canceled(jcr) || jcr->sd_msg_thread_done) {
          return false;
@@ -391,7 +391,7 @@ extern "C" void msg_thread_cleanup(void *arg)
    db_end_transaction(jcr, jcr->db);        /* terminate any open transaction */
    jcr->lock();
    jcr->sd_msg_thread_done = true;
-   jcr->SD_msg_chan = 0;
+   jcr->SD_msg_chan_started = false;
    jcr->unlock();
    pthread_cond_broadcast(&jcr->term_wait); /* wakeup any waiting threads */
    Dmsg2(100, "=== End msg_thread. JobId=%d usecnt=%d\n", jcr->JobId, jcr->use_count());
@@ -417,6 +417,7 @@ extern "C" void *msg_thread(void *arg)
    pthread_detach(pthread_self());
    set_jcr_in_tsd(jcr);
    jcr->SD_msg_chan = pthread_self();
+   jcr->SD_msg_chan_started = true;
    pthread_cleanup_push(msg_thread_cleanup, arg);
    sd = jcr->store_bsock;
 
@@ -472,7 +473,7 @@ void wait_for_storage_daemon_termination(JCR *jcr)
       pthread_cond_timedwait(&jcr->term_wait, &mutex, &timeout);
       V(mutex);
       if (jcr->is_canceled()) {
-         if (jcr->SD_msg_chan) {
+         if (jcr->SD_msg_chan_started) {
             jcr->store_bsock->set_timed_out();
             jcr->store_bsock->set_terminated();
             sd_msg_thread_send_signal(jcr, TIMEOUT_SIGNAL);
index 3c11120e73e84f2e1142c95299cc8e09dec07814..99bffc6706e866a4d63bdd46e6c909a57b2c62e8 100644 (file)
@@ -595,7 +595,7 @@ void restore_cleanup(JCR *jcr, int TermCode)
       msg_type = M_ERROR;          /* Generate error message */
       if (jcr->store_bsock) {
          jcr->store_bsock->signal(BNET_TERMINATE);
-         if (jcr->SD_msg_chan) {
+         if (jcr->SD_msg_chan_started) {
             pthread_cancel(jcr->SD_msg_chan);
          }
       }
@@ -604,7 +604,7 @@ void restore_cleanup(JCR *jcr, int TermCode)
       term_msg = _("Restore Canceled");
       if (jcr->store_bsock) {
          jcr->store_bsock->signal(BNET_TERMINATE);
-         if (jcr->SD_msg_chan) {
+         if (jcr->SD_msg_chan_started) {
             pthread_cancel(jcr->SD_msg_chan);
          }
       }
index 8430c74dfd95892d48072bea0662dea78fdf97f1..64d69bb66f4c4e59f99dfecc460c89921aaf16f7 100644 (file)
@@ -392,7 +392,7 @@ void vbackup_cleanup(JCR *jcr, int TermCode)
          msg_type = M_ERROR;          /* Generate error message */
          if (jcr->store_bsock) {
             jcr->store_bsock->signal(BNET_TERMINATE);
-            if (jcr->SD_msg_chan) {
+            if (jcr->SD_msg_chan_started) {
                pthread_cancel(jcr->SD_msg_chan);
             }
          }
@@ -401,7 +401,7 @@ void vbackup_cleanup(JCR *jcr, int TermCode)
          term_msg = _("Backup Canceled");
          if (jcr->store_bsock) {
             jcr->store_bsock->signal(BNET_TERMINATE);
-            if (jcr->SD_msg_chan) {
+            if (jcr->SD_msg_chan_started) {
                pthread_cancel(jcr->SD_msg_chan);
             }
          }
index 5ffc1421a02f9c26d89ec653f014fbc6262b286d..ef565930143ae05b1dffa81590ecfaa59e1e59ed 100644 (file)
@@ -349,6 +349,7 @@ public:
    int32_t SDVersion;                 /* Storage daemon version number */
    int64_t spool_size;                /* Spool size for this job */
    volatile bool sd_msg_thread_done;  /* Set when Storage message thread done */
+   bool SD_msg_chan_started;          /* Set if message thread started */
    bool wasVirtualFull;               /* set if job was VirtualFull */
    bool IgnoreDuplicateJobChecking;   /* set in migration jobs */
    bool spool_data;                   /* Spool data in SD */