]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix FreeBSD mutex problem in stored.c
authorKern Sibbald <kern@sibbald.com>
Sun, 29 Dec 2002 20:04:17 +0000 (20:04 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 29 Dec 2002 20:04:17 +0000 (20:04 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@254 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/ChangeLog
bacula/src/stored/stored.c

index 03e80ce04aee68be6baed478d315a246d83d91ec..7d3e623f07696948170733f355f41e68377fb30c 100644 (file)
@@ -16,6 +16,9 @@ Changes submitted this submission:
 - Added --enable-client-only to ./configure
 - Modified --enable-static-sd to work better and documented it.
 - Fixed Restore options (never,ifnewer, ...). They now work.
+- Moved the stored.c Resource lock into the allocation thread so
+  that the same thread sets/clears it. This created a problem on
+  FreeBSD.
 28Dec02
 - Added more rescue documentation.
 - Did a spell check of the Bacula doc.
index 35d50f4a8ab35f248fc357a6753f24334ab7e0de..91b360891b8f4769319ba2e701de9fc02d0d4a15 100644 (file)
@@ -183,22 +183,21 @@ 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);
 
-   /*                           
-    * Here we lock the resources then fire off the device allocation
-    *  thread. That thread will release the resources when all the
-    *  devices are allocated.  This allows use to start the server
-    *  right away, but any jobs will wait until the resources are
-    *  unlocked.       
-    */
-   LockRes();
+    /*
+     * Start the device allocation thread
+     */
    if (pthread_create(&thid, NULL, device_allocation, NULL) != 0) {
       Emsg1(M_ABORT, 0, _("Unable to create thread. ERR=%s\n"), strerror(errno));
    }
 
-
-
    start_watchdog();                 /* start watchdog thread */
 
+   /* 
+    * Sleep a bit to give device thread a chance to lock the resource
+    * chain before we start the server.
+    */
+   sleep(1); 
+                                
    /* Single server used for Director and File daemon */
    bnet_thread_server(me->SDaddr, me->SDport, me->max_concurrent_jobs * 2 + 1,
                      &dird_workq, connection_request);
@@ -283,9 +282,9 @@ static void *device_allocation(void *arg)
    int i;
    DEVRES *device;
 
+   LockRes();
    pthread_detach(pthread_self());
 
-   /* LockRes() alread done */
    for (device=NULL,i=0;  (device=(DEVRES *)GetNextRes(R_DEVICE, (RES *)device)); i++) {
       Dmsg1(90, "calling init_dev %s\n", device->device_name);
       device->dev = init_dev(NULL, device);