]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/stored.c
Move reservations message lock to lock jcr only this
[bacula/bacula] / bacula / src / stored / stored.c
index efe7c5a416e2479301d78b8824e59a0fc891ef33..996f4fc358956d80e0708a4f7d0b0f2ffe6dca85 100644 (file)
@@ -7,8 +7,8 @@
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
    modify it under the terms of version two of the GNU General Public
-   License as published by the Free Software Foundation plus additions
-   that are listed in the file LICENSE.
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
 
    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -61,6 +61,7 @@ STORES *me = NULL;                    /* our Global resource */
 bool forge_on = false;                /* proceed inspite of I/O errors */
 pthread_mutex_t device_release_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_cond_t wait_device_release = PTHREAD_COND_INITIALIZER;
+void *start_heap;
 
 
 static uint32_t VolSessionId = 0;
@@ -112,6 +113,7 @@ int main (int argc, char *argv[])
    char *uid = NULL;
    char *gid = NULL;
 
+   start_heap = sbrk(0);
    setlocale(LC_ALL, "");
    bindtextdomain("bacula", LOCALEDIR);
    textdomain("bacula");
@@ -481,7 +483,7 @@ void *device_initialization(void *arg)
          continue;
       }
 
-      jcr->dcr = dcr = new_dcr(jcr, dev);
+      jcr->dcr = dcr = new_dcr(jcr, NULL, dev);
       if (dev->is_autochanger()) {
          /* If autochanger set slot in dev sturcture */
          get_autochanger_loaded_slot(dcr);
@@ -535,6 +537,7 @@ void terminate_stored(int sig)
       exit(1);
    }
    in_here = true;
+   stop_watchdog();
 
    if (sig == SIGTERM) {              /* normal shutdown request? */
       /*
@@ -552,12 +555,13 @@ void terminate_stored(int sig)
          set_jcr_job_status(jcr, JS_Canceled);
          fd = jcr->file_bsock;
          if (fd) {
-            fd->timed_out = true;
+            fd->set_timed_out();
             Dmsg1(100, "term_stored killing JobId=%d\n", jcr->JobId);
             pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
             /* ***FIXME*** wiffle through all dcrs */
             if (jcr->dcr && jcr->dcr->dev && jcr->dcr->dev->blocked()) {
                pthread_cond_broadcast(&jcr->dcr->dev->wait_next_vol);
+               Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)jcr->JobId);
                pthread_cond_broadcast(&wait_device_release);
             }
             if (jcr->read_dcr && jcr->read_dcr->dev && jcr->read_dcr->dev->blocked()) {
@@ -598,7 +602,6 @@ void terminate_stored(int sig)
    }
    term_reservations_lock();
    term_msg();
-   stop_watchdog();
    cleanup_crypto();
    free_volume_list();
    close_memory_pool();