]> git.sur5r.net Git - bacula/bacula/commitdiff
- Fix bug in changing tape pools after first backup. Reported
authorKern Sibbald <kern@sibbald.com>
Mon, 9 May 2005 11:51:20 +0000 (11:51 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 9 May 2005 11:51:20 +0000 (11:51 +0000)
  by Peter Sjoberg.
- Enhance mtx-changer to use Working Directory as temp.
- Remove all but initial setup locking of Res in SD.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2015 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/scripts/mtx-changer.in
bacula/src/stored/acquire.c
bacula/src/stored/authenticate.c
bacula/src/stored/dircmd.c
bacula/src/stored/job.c
bacula/src/stored/status.c
bacula/src/stored/stored.c
bacula/src/version.h

index f0c885ac11c83beb799b5279c792c3204d6e8eb0..1f9307dfa67b5095c837cdbdc109f36769aca9be 100644 (file)
@@ -28,6 +28,8 @@
 #
 
 MTX=@MTX@
+# Set this to a directory that only the SD can read/write
+TMPDIR=@working_dir@
 
 #
 # The purpose of this function to wait a maximum 
@@ -130,11 +132,11 @@ case $cmd in
       ;;
 
    loaded)
-      ${MTX} -f $ctl status >/tmp/mtx.$$
+      ${MTX} -f $ctl status >${TMPDIR}/mtx.$$
       rtn=$?
-      cat /tmp/mtx.$$ | grep "^Data Transfer Element $drive:Full" | awk "{print \$7}"
-      cat /tmp/mtx.$$ | grep "^Data Transfer Element $drive:Empty" | awk "{print 0}"
-      rm -f /tmp/mtx.$$
+      cat ${TMPDIR}/mtx.$$ | grep "^Data Transfer Element $drive:Full" | awk "{print \$7}"
+      cat ${TMPDIR}/mtx.$$ | grep "^Data Transfer Element $drive:Empty" | awk "{print 0}"
+      rm -f ${TMPDIR}/mtx.$$
       exit $rtn
       ;;
 
index 45e0fb3ac9b6aadd0484c6f6897b0148b436bf25..10cd5ef8720a073a7ad93ac247406c13749781df 100644 (file)
@@ -463,7 +463,18 @@ static int can_reserve_drive(DCR *dcr)
    }
 
    /*
-    * Now check if the device is in append mode 
+    * Check if device in append mode with no writers (i.e. available)
+    */
+   if (dev->can_append() && dev->num_writers == 0) {
+      /* Device is available but not yet reserved, reserve it for us */
+      bstrncpy(dev->pool_name, dcr->pool_name, sizeof(dev->pool_name));
+      bstrncpy(dev->pool_type, dcr->pool_type, sizeof(dev->pool_type));
+      return 1;
+   }
+
+   /*
+    * Now check if the device is in append mode with writers (i.e.
+    *  available if pool is the same).
     */
    if (dev->can_append() || dev->num_writers > 0) {
       Dmsg0(190, "device already in append.\n");
index 7b3eb759016baa112a5b1e173d7d73087d73e4de..270cc51c939e3c7fa44ede78f44298fd1b0a8dac 100644 (file)
@@ -55,9 +55,9 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
    }
    if (bs->msglen < 25 || bs->msglen > 200) {
       Dmsg2(50, _("Bad Hello command from Director at %s. Len=%d.\n"),
-           bs->who, bs->msglen);
+            bs->who, bs->msglen);
       Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s. Len=%d.\n"),
-           bs->who, bs->msglen);
+            bs->who, bs->msglen);
       return 0;
    }
    dirname = get_pool_memory(PM_MESSAGE);
@@ -66,25 +66,25 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
    if (sscanf(bs->msg, "Hello Director %127s calling\n", dirname) != 1) {
       bs->msg[100] = 0;
       Dmsg2(50, _("Bad Hello command from Director at %s: %s\n"),
-           bs->who, bs->msg);
+            bs->who, bs->msg);
       Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s: %s\n"),
-           bs->who, bs->msg);
+            bs->who, bs->msg);
       return 0;
    }
    director = NULL;
    unbash_spaces(dirname);
-   LockRes();
+// LockRes();
    foreach_res(director, rcode) {
       if (strcmp(director->hdr.name, dirname) == 0)
-        break;
+         break;
    }
-   UnlockRes();
+// UnlockRes();
    if (!director) {
       Dmsg2(50, _("Connection from unknown Director %s at %s rejected.\n"),
-           dirname, bs->who);
+            dirname, bs->who);
       Emsg2(M_FATAL, 0, _("Connection from unknown Director %s at %s rejected.\n"
        "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"),
-           dirname, bs->who);
+            dirname, bs->who);
       free_pool_memory(dirname);
       return 0;
    }
@@ -95,7 +95,7 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
       if (director->tls_require) {
          tls_local_need = BNET_TLS_REQUIRED;
       } else {
-        tls_local_need = BNET_TLS_OK;
+         tls_local_need = BNET_TLS_OK;
       }
    }
 
@@ -110,7 +110,7 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
    if (auth_success) {
       auth_success = cram_md5_get_auth(bs, director->password, &tls_remote_need);
       if (!auth_success) {
-        Dmsg1(50, "cram_get_auth failed with %s\n", bs->who);
+         Dmsg1(50, "cram_get_auth failed with %s\n", bs->who);
       }
    } else {
       Dmsg1(50, "cram_auth failed with %s\n", bs->who);
@@ -126,7 +126,7 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
    /* Verify that the remote host is willing to meet our TLS requirements */
    if (tls_remote_need < tls_local_need && tls_local_need != BNET_TLS_OK && tls_remote_need != BNET_TLS_OK) {
       Emsg0(M_FATAL, 0, _("Authorization problem: Remote server did not" 
-          " advertise required TLS support.\n"));
+           " advertise required TLS support.\n"));
       auth_success = false;
       goto auth_fatal;
    }
@@ -142,9 +142,9 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
    if (tls_local_need >= BNET_TLS_OK && tls_remote_need >= BNET_TLS_OK) {
       /* Engage TLS! Full Speed Ahead! */
       if (!bnet_tls_server(director->tls_ctx, bs, verify_list)) {
-        Emsg0(M_FATAL, 0, "TLS negotiation failed.\n");
-        auth_success = false;
-        goto auth_fatal;
+         Emsg0(M_FATAL, 0, "TLS negotiation failed.\n");
+         auth_success = false;
+         goto auth_fatal;
       }
    }
 #endif /* HAVE_TLS */
@@ -162,7 +162,7 @@ auth_fatal:
  *
  * Basic tasks done here:
  *   Assume the Hello message is already in the input
- *     buffer. We then authenticate him.
+ *     buffer.  We then authenticate him.
  *   Get device, media, and pool information from Director
  *
  *   This is the channel across which we will send error
@@ -198,7 +198,7 @@ int authenticate_filed(JCR *jcr)
       if (me->tls_require) {
          tls_local_need = BNET_TLS_REQUIRED;
       } else {
-        tls_local_need = BNET_TLS_OK;
+         tls_local_need = BNET_TLS_OK;
       }
    }
 
@@ -213,7 +213,7 @@ int authenticate_filed(JCR *jcr)
    if (auth_success) {
        auth_success = cram_md5_get_auth(fd, jcr->sd_auth_key, &tls_remote_need);
        if (!auth_success) {
-         Dmsg1(50, "cram-get-auth failed with %s\n", fd->who);
+          Dmsg1(50, "cram-get-auth failed with %s\n", fd->who);
        }
    } else {
       Dmsg1(50, "cram-auth failed with %s\n", fd->who);
@@ -222,7 +222,7 @@ int authenticate_filed(JCR *jcr)
    if (!auth_success) {
       Jmsg(jcr, M_FATAL, 0, _("Incorrect authorization key from File daemon at %s rejected.\n"
        "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"),
-          fd->who);
+           fd->who);
       auth_success = false;
       goto auth_fatal;
    }
@@ -230,7 +230,7 @@ int authenticate_filed(JCR *jcr)
    /* Verify that the remote host is willing to meet our TLS requirements */
    if (tls_remote_need < tls_local_need && tls_local_need != BNET_TLS_OK && tls_remote_need != BNET_TLS_OK) {
       Jmsg(jcr, M_FATAL, 0, _("Authorization problem: Remote server did not" 
-          " advertise required TLS support.\n"));
+           " advertise required TLS support.\n"));
       auth_success = false;
       goto auth_fatal;
    }
@@ -246,9 +246,9 @@ int authenticate_filed(JCR *jcr)
    if (tls_local_need >= BNET_TLS_OK && tls_remote_need >= BNET_TLS_OK) {
       /* Engage TLS! Full Speed Ahead! */
       if (!bnet_tls_server(me->tls_ctx, fd, verify_list)) {
-        Jmsg(jcr, M_FATAL, 0, "TLS negotiation failed.\n");
-        auth_success = false;
-        goto auth_fatal;
+         Jmsg(jcr, M_FATAL, 0, "TLS negotiation failed.\n");
+         auth_success = false;
+         goto auth_fatal;
       }
    }
 #endif /* HAVE_TLS */
@@ -258,7 +258,7 @@ auth_fatal:
    if (!auth_success) {
       Jmsg(jcr, M_FATAL, 0, _("Incorrect authorization key from File daemon at %s rejected.\n"
        "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"),
-          fd->who);
+           fd->who);
    }
    jcr->authenticated = auth_success;
    return auth_success;
index 02c2fc91690c66e4cc9f55c620ee8d8db84caa60..acf10f6151075cf8a7c46d37393aa6d0ca06e3da 100644 (file)
@@ -476,7 +476,7 @@ static DEVICE *find_device(JCR *jcr, POOL_MEM &devname)
    bool found = false;
 
    unbash_spaces(devname);
-   LockRes();
+// LockRes();
    foreach_res(device, R_DEVICE) {
       /* Find resource, and make sure we were able to open it */
       if (fnmatch(device->hdr.name, devname.c_str(), 0) == 0) {
@@ -523,11 +523,11 @@ static DEVICE *find_device(JCR *jcr, POOL_MEM &devname)
 
    if (found) {
       jcr->dcr = new_dcr(jcr, device->dev);
-      UnlockRes();
+//    UnlockRes();
       jcr->dcr->device = device;
       return jcr->dcr->dev;
    }
-   UnlockRes();
+// UnlockRes();
    return NULL;
 }
 
index 6bde98a8a702337ccf7e4fd65d5c52286ba111f4..d0b2e4219a1160bb61dae2c603f70099700ac0a8 100644 (file)
@@ -334,7 +334,7 @@ static bool use_storage_cmd(JCR *jcr)
 
 
    if (ok) {
-      LockRes();
+//    LockRes();
       store = (DIRSTORE *)dirstore->first();
       foreach_alist(device_name, store->device) {
          foreach_res(device, R_DEVICE) {
@@ -343,7 +343,7 @@ static bool use_storage_cmd(JCR *jcr)
                 strcmp(device->media_type, store->media_type) == 0) {
                const int name_len = MAX_NAME_LENGTH;
                DCR *dcr;
-               UnlockRes();
+//             UnlockRes();
                if (!device->dev) {
                   device->dev = init_dev(jcr, NULL, device);
                }
@@ -412,7 +412,7 @@ static bool use_storage_cmd(JCR *jcr)
                   if (!dcr) {
                      bnet_fsend(dir, _("3926 Could not get dcr for device: %s\n"), dev_name.c_str());
                      Dmsg1(100, ">dird: %s\n", dir->msg);
-                     UnlockRes();
+//                   UnlockRes();
                      ok = false;
                      goto get_out;
                   }
@@ -433,7 +433,7 @@ static bool use_storage_cmd(JCR *jcr)
                      continue;
                   }
                   Dmsg1(100, "Device %s opened.\n", device_name);
-                  UnlockRes();
+//                UnlockRes();
                   pm_strcpy(dev_name, device->hdr.name);
                   bash_spaces(dev_name);
                   ok = bnet_fsend(dir, OK_device, dev_name.c_str());
@@ -445,7 +445,7 @@ static bool use_storage_cmd(JCR *jcr)
          }
       }
 
-      UnlockRes();
+//    UnlockRes();
       if (verbose) {
          unbash_spaces(dir->msg);
          pm_strcpy(jcr->errmsg, dir->msg);
@@ -500,7 +500,7 @@ bool query_cmd(JCR *jcr)
    Dmsg1(100, "<dird: %s\n", dir->msg);
    if (ok) {
       unbash_spaces(dev_name);
-      LockRes();
+//    LockRes();
       foreach_res(device, R_DEVICE) {
          /* Find resource, and make sure we were able to open it */
          if (fnmatch(dev_name.c_str(), device->hdr.name, 0) == 0) {
@@ -510,7 +510,7 @@ bool query_cmd(JCR *jcr)
             if (!device->dev) {
                break;
             }  
-            UnlockRes();
+//          UnlockRes();
             ok = dir_update_device(jcr, device->dev);
             if (ok) {
                ok = bnet_fsend(dir, OK_query);
@@ -523,7 +523,7 @@ bool query_cmd(JCR *jcr)
       foreach_res(changer, R_AUTOCHANGER) {
          /* Find resource, and make sure we were able to open it */
          if (fnmatch(dev_name.c_str(), changer->hdr.name, 0) == 0) {
-            UnlockRes();
+//          UnlockRes();
             if (!changer->device || changer->device->size() == 0) {
                continue;              /* no devices */
             }
@@ -537,7 +537,7 @@ bool query_cmd(JCR *jcr)
          }
       }
       /* If we get here, the device/autochanger was not found */
-      UnlockRes();
+//    UnlockRes();
       unbash_spaces(dir->msg);
       pm_strcpy(jcr->errmsg, dir->msg);
       bnet_fsend(dir, NO_device, dev_name.c_str());
index adc31aba44b0450194c05769e2846f1d17aac7d0..093e91e374a06a622662cfe07d58e1e4df015050 100644 (file)
@@ -68,17 +68,17 @@ bool status_cmd(JCR *jcr)
    int bpb;
 
    bnet_fsend(user, "\n%s Version: " VERSION " (" BDATE ") %s %s %s\n", my_name,
-             HOST_OS, DISTNAME, DISTVER);
+              HOST_OS, DISTNAME, DISTVER);
    bstrftime_nc(dt, sizeof(dt), daemon_start_time);
    bnet_fsend(user, _("Daemon started %s, %d Job%s run since started.\n"), dt, num_jobs_run,
         num_jobs_run == 1 ? "" : "s");
    if (debug_level > 0) {
       char b1[35], b2[35], b3[35], b4[35];
       bnet_fsend(user, _(" Heap: bytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"),
-           edit_uint64_with_commas(sm_bytes, b1),
-           edit_uint64_with_commas(sm_max_bytes, b2),
-           edit_uint64_with_commas(sm_buffers, b3),
-           edit_uint64_with_commas(sm_max_buffers, b4));
+            edit_uint64_with_commas(sm_bytes, b1),
+            edit_uint64_with_commas(sm_max_bytes, b2),
+            edit_uint64_with_commas(sm_buffers, b3),
+            edit_uint64_with_commas(sm_max_buffers, b4));
    }
 
    /*
@@ -95,53 +95,53 @@ bool status_cmd(JCR *jcr)
     * List devices
     */
    bnet_fsend(user, _("\nDevice status:\n"));
-   LockRes();
+// LockRes();
    foreach_res(device, R_DEVICE) {
       dev = device->dev;
       if (dev && dev->is_open()) {
-        if (dev->is_labeled()) {
+         if (dev->is_labeled()) {
             bnet_fsend(user, _("Device %s is mounted with Volume \"%s\"\n"),
-              dev->print_name(), dev->VolHdr.VolName);
-        } else {
+               dev->print_name(), dev->VolHdr.VolName);
+         } else {
             bnet_fsend(user, _("Device %s open but no Bacula volume is mounted.\n"), 
-              dev->print_name());
-        }
-        send_blocked_status(jcr, dev);
-        if (dev->can_append()) {
-           bpb = dev->VolCatInfo.VolCatBlocks;
-           if (bpb <= 0) {
-              bpb = 1;
-           }
-           bpb = dev->VolCatInfo.VolCatBytes / bpb;
+               dev->print_name());
+         }
+         send_blocked_status(jcr, dev);
+         if (dev->can_append()) {
+            bpb = dev->VolCatInfo.VolCatBlocks;
+            if (bpb <= 0) {
+               bpb = 1;
+            }
+            bpb = dev->VolCatInfo.VolCatBytes / bpb;
             bnet_fsend(user, _("    Total Bytes=%s Blocks=%s Bytes/block=%s\n"),
-              edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1),
-              edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2),
-              edit_uint64_with_commas(bpb, b3));
-        } else {  /* reading */
-           bpb = dev->VolCatInfo.VolCatReads;
-           if (bpb <= 0) {
-              bpb = 1;
-           }
-           if (dev->VolCatInfo.VolCatRBytes > 0) {
-              bpb = dev->VolCatInfo.VolCatRBytes / bpb;
-           } else {
-              bpb = 0;
-           }
+               edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1),
+               edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2),
+               edit_uint64_with_commas(bpb, b3));
+         } else {  /* reading */
+            bpb = dev->VolCatInfo.VolCatReads;
+            if (bpb <= 0) {
+               bpb = 1;
+            }
+            if (dev->VolCatInfo.VolCatRBytes > 0) {
+               bpb = dev->VolCatInfo.VolCatRBytes / bpb;
+            } else {
+               bpb = 0;
+            }
             bnet_fsend(user, _("    Total Bytes Read=%s Blocks Read=%s Bytes/block=%s\n"),
-              edit_uint64_with_commas(dev->VolCatInfo.VolCatRBytes, b1),
-              edit_uint64_with_commas(dev->VolCatInfo.VolCatReads, b2),
-              edit_uint64_with_commas(bpb, b3));
-        }
+               edit_uint64_with_commas(dev->VolCatInfo.VolCatRBytes, b1),
+               edit_uint64_with_commas(dev->VolCatInfo.VolCatReads, b2),
+               edit_uint64_with_commas(bpb, b3));
+         }
          bnet_fsend(user, _("    Positioned at File=%s Block=%s\n"),
-           edit_uint64_with_commas(dev->file, b1),
-           edit_uint64_with_commas(dev->block_num, b2));
+            edit_uint64_with_commas(dev->file, b1),
+            edit_uint64_with_commas(dev->block_num, b2));
 
       } else {
          bnet_fsend(user, _("Archive \"%s\" is not open or does not exist.\n"), device->hdr.name);
-        send_blocked_status(jcr, dev);
+         send_blocked_status(jcr, dev);
       }
    }
-   UnlockRes();
+// UnlockRes();
 
 #ifdef xxx
    if (debug_level > 0) {
@@ -175,7 +175,7 @@ static void send_blocked_status(JCR *jcr, DEVICE *dev)
    case BST_WAITING_FOR_SYSOP:
       if (jcr->JobStatus == JS_WaitMount) {
          bnet_fsend(user, _("    Device is BLOCKED waiting for mount of volume \"%s\".\n"),
-           dcr->VolumeName);
+            dcr->VolumeName);
       } else {
          bnet_fsend(user, _("    Device is BLOCKED waiting for media.\n"));
       }
@@ -220,11 +220,11 @@ static void send_blocked_status(JCR *jcr, DEVICE *dev)
       bnet_fsend(user, "%sMOUNTED ", dev->state & ST_MOUNTED ? "" : "!");
       bnet_fsend(user, "\n");
       bnet_fsend(user, "num_writers=%d JobStatus=%c block=%d\nn", dev->num_writers,
-        jcr->JobStatus, dev->dev_blocked);
+         jcr->JobStatus, dev->dev_blocked);
 
       bnet_fsend(user, _("Device parameters:\n"));
       bnet_fsend(user, "Archive name: %s Device name: %s\n", dev->archive_name(),
-        dev->name());
+         dev->name());
       bnet_fsend(user, "File=%u block=%u\n", dev->file, dev->block_num);
       bnet_fsend(user, "Min block=%u Max block=%u\n", dev->min_block_size, dev->max_block_size);
    }
@@ -244,43 +244,43 @@ static void list_running_jobs(BSOCK *user)
    foreach_jcr(jcr) {
       if (jcr->JobStatus == JS_WaitFD) {
          bnet_fsend(user, _("%s Job %s waiting for Client connection.\n"),
-           job_type_to_str(jcr->JobType), jcr->Job);
+            job_type_to_str(jcr->JobType), jcr->Job);
       }
       if (jcr->dcr && jcr->dcr->device) {
-        bstrncpy(JobName, jcr->Job, sizeof(JobName));
-        /* There are three periods after the Job name */
-        char *p;
-        for (int i=0; i<3; i++) {
+         bstrncpy(JobName, jcr->Job, sizeof(JobName));
+         /* There are three periods after the Job name */
+         char *p;
+         for (int i=0; i<3; i++) {
             if ((p=strrchr(JobName, '.')) != NULL) {
-              *p = 0;
-           }
-        }
+               *p = 0;
+            }
+         }
          bnet_fsend(user, _("%s %s job %s JobId=%d Volume=\"%s\" device=\"%s\"\n"),
-                  job_level_to_str(jcr->JobLevel),
-                  job_type_to_str(jcr->JobType),
-                  JobName,
-                  jcr->JobId,
-                  jcr->dcr->VolumeName,
-                  jcr->dcr->device->device_name);
-        sec = time(NULL) - jcr->run_time;
-        if (sec <= 0) {
-           sec = 1;
-        }
-        bps = jcr->JobBytes / sec;
+                   job_level_to_str(jcr->JobLevel),
+                   job_type_to_str(jcr->JobType),
+                   JobName,
+                   jcr->JobId,
+                   jcr->dcr->VolumeName,
+                   jcr->dcr->device->device_name);
+         sec = time(NULL) - jcr->run_time;
+         if (sec <= 0) {
+            sec = 1;
+         }
+         bps = jcr->JobBytes / sec;
          bnet_fsend(user, _("    Files=%s Bytes=%s Bytes/sec=%s\n"),
-           edit_uint64_with_commas(jcr->JobFiles, b1),
-           edit_uint64_with_commas(jcr->JobBytes, b2),
-           edit_uint64_with_commas(bps, b3));
-        found = true;
+            edit_uint64_with_commas(jcr->JobFiles, b1),
+            edit_uint64_with_commas(jcr->JobBytes, b2),
+            edit_uint64_with_commas(bps, b3));
+         found = true;
 #ifdef DEBUG
-        if (jcr->file_bsock) {
+         if (jcr->file_bsock) {
             bnet_fsend(user, "    FDReadSeqNo=%s in_msg=%u out_msg=%d fd=%d\n",
-              edit_uint64_with_commas(jcr->file_bsock->read_seqno, b1),
-              jcr->file_bsock->in_msg_no, jcr->file_bsock->out_msg_no,
-              jcr->file_bsock->fd);
-        } else {
+               edit_uint64_with_commas(jcr->file_bsock->read_seqno, b1),
+               jcr->file_bsock->in_msg_no, jcr->file_bsock->out_msg_no,
+               jcr->file_bsock->fd);
+         } else {
             bnet_fsend(user, "    FDSocket closed\n");
-        }
+         }
 #endif
       }
       free_locked_jcr(jcr);
@@ -321,48 +321,48 @@ static void list_terminated_jobs(void *arg)
       case JT_ADMIN:
       case JT_RESTORE:
          bstrncpy(level, "    ", sizeof(level));
-        break;
+         break;
       default:
-        bstrncpy(level, level_to_str(je->JobLevel), sizeof(level));
-        level[4] = 0;
-        break;
+         bstrncpy(level, level_to_str(je->JobLevel), sizeof(level));
+         level[4] = 0;
+         break;
       }
       switch (je->JobStatus) {
       case JS_Created:
          termstat = "Created";
-        break;
+         break;
       case JS_FatalError:
       case JS_ErrorTerminated:
          termstat = "Error";
-        break;
+         break;
       case JS_Differences:
          termstat = "Diffs";
-        break;
+         break;
       case JS_Canceled:
          termstat = "Cancel";
-        break;
+         break;
       case JS_Terminated:
          termstat = "OK";
-        break;
+         break;
       default:
          termstat = "Other";
-        break;
+         break;
       }
       bstrncpy(JobName, je->Job, sizeof(JobName));
       /* There are three periods after the Job name */
       char *p;
       for (int i=0; i<3; i++) {
          if ((p=strrchr(JobName, '.')) != NULL) {
-           *p = 0;
-        }
+            *p = 0;
+         }
       }
       bsnprintf(buf, sizeof(buf), _("%6d  %-6s %8s %14s %-7s  %-8s %s\n"),
-        je->JobId,
-        level,
-        edit_uint64_with_commas(je->JobFiles, b1),
-        edit_uint64_with_commas(je->JobBytes, b2),
-        termstat,
-        dt, JobName);
+         je->JobId,
+         level,
+         edit_uint64_with_commas(je->JobFiles, b1),
+         edit_uint64_with_commas(je->JobBytes, b2),
+         termstat,
+         dt, JobName);
       sendit(buf, strlen(buf), arg);
    }
    sendit("====\n", 5, arg);
@@ -451,18 +451,18 @@ bool qstatus_cmd(JCR *jcr)
       bnet_fsend(dir, OKqstatus, time.c_str());
       lock_jcr_chain();
       foreach_jcr(njcr) {
-        if (njcr->JobId != 0) {
-           bnet_fsend(dir, DotStatusJob, njcr->JobId, njcr->JobStatus, njcr->JobErrors);
-        }
-        free_locked_jcr(njcr);
+         if (njcr->JobId != 0) {
+            bnet_fsend(dir, DotStatusJob, njcr->JobId, njcr->JobStatus, njcr->JobErrors);
+         }
+         free_locked_jcr(njcr);
       }
       unlock_jcr_chain();
    }
    else if (strcmp(time.c_str(), "last") == 0) {
       bnet_fsend(dir, OKqstatus, time.c_str());
       if ((last_jobs) && (last_jobs->size() > 0)) {
-        job = (s_last_job*)last_jobs->last();
-        bnet_fsend(dir, DotStatusJob, job->JobId, job->JobStatus, job->Errors);
+         job = (s_last_job*)last_jobs->last();
+         bnet_fsend(dir, DotStatusJob, job->JobId, job->JobStatus, job->Errors);
       }
    }
    else {
index 49ff47b2df87a3eaa2c27a10170aaf61a87e1f92..5d6d3e0b349a002685724f72715062ed047b318b 100644 (file)
@@ -239,6 +239,10 @@ int main (int argc, char *argv[])
     */
    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);
@@ -263,7 +267,7 @@ static int check_resources()
    bool OK = true;
    AUTOCHANGER *changer;
 
-   LockRes();
+// LockRes();
 
    me = (STORES *)GetNextRes(R_STORAGE, NULL);
    if (!me) {
@@ -426,7 +430,7 @@ static int check_resources()
       }
    }
    
-   UnlockRes();
+// UnlockRes();
 
    if (OK) {
       close_msg(NULL);                   /* close temp message handler */
@@ -541,13 +545,13 @@ void terminate_stored(int sig)
 
    Dmsg1(200, "In terminate_stored() sig=%d\n", sig);
 
-   LockRes();
+// LockRes();
    foreach_res(device, R_DEVICE) {
       if (device->dev) {
          term_dev(device->dev);
       }
    }
-   UnlockRes();
+// UnlockRes();
 
    if (configfile)
    free(configfile);
index 06a270af30855aafe2a75abec919b87fde250dc4..3e8c5cfc9c9d646a5cd257b13d300674cc98a393 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #undef  VERSION
 #define VERSION "1.37.18"
-#define BDATE   "08 May 2005"
-#define LSMDATE "08May05"
+#define BDATE   "09 May 2005"
+#define LSMDATE "09May05"
 
 /* Debug flags */
 #undef  DEBUG