]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/stored.c
I finally found and squashed the elusive SD crash.
[bacula/bacula] / bacula / src / stored / stored.c
index fc45fcf314db89c76488521201cba776efdc0c26..b91718ed486885119280e360242e83625754ac9d 100644 (file)
@@ -50,6 +50,7 @@ pthread_cond_t wait_device_release = PTHREAD_COND_INITIALIZER;
 static uint32_t VolSessionId = 0;
 uint32_t VolSessionTime;
 char *configfile = NULL;
+bool init_done = false;
 
 /* Global static variables */
 static int foreground = 0;
@@ -217,28 +218,17 @@ int main (int argc, char *argv[])
    /* Make sure on Solaris we can run concurrent, watch dog + servers + misc */
    set_thread_concurrency(me->max_concurrent_jobs * 2 + 4);
 
-   create_volume_list();
     /*
      * Start the device allocation thread
      */
+   create_volume_list();              /* do before device_init */
    if (pthread_create(&thid, NULL, device_initialization, NULL) != 0) {
       Emsg1(M_ABORT, 0, _("Unable to create thread. ERR=%s\n"), strerror(errno));
    }
 
    start_watchdog();                  /* start watchdog thread */
-
    init_jcr_subsystem();              /* start JCR watchdogs etc. */
 
-   /*
-    * Sleep a bit to give device thread a chance to lock the resource
-    * chain before we start the server.
-    */
-   bmicrosleep(1, 0);
-
-   /* Wait for device initialization to complete */
-   LockRes();
-   UnlockRes();
-
    /* Single server used for Director and File daemon */
    bnet_thread_server(me->sdaddrs, me->max_concurrent_jobs * 2 + 1,
                       &dird_workq, handle_connection_request);
@@ -510,6 +500,7 @@ void *device_initialization(void *arg)
       free_dcr(dcr);
    }
    free_jcr(jcr); 
+   init_done = true;
    UnlockRes();
    return NULL;
 }