X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Fdircmd.c;h=47370524a1296ab52f3e7e06913d45cba8df1c5d;hb=3227fb78cccb8cf93511f0ee55a21aff8f372ab9;hp=b61e2e66305f9f7d29791aa808067dbf5291a10b;hpb=ba91e64a8bc84c321c0319bd45cb7175430e430b;p=bacula%2Fbacula diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index b61e2e6630..47370524a1 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Bacula® is a registered trademark of John Walker. + Bacula® is a registered trademark of Kern Sibbald. The licensor of Bacula is the Free Software Foundation Europe (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. @@ -54,8 +54,6 @@ /* Imported variables */ extern BSOCK *filed_chan; -extern int r_first, r_last; -extern struct s_res resources[]; extern struct s_last_job last_job; extern bool init_done; @@ -97,7 +95,7 @@ static void send_dir_busy_message(BSOCK *dir, DEVICE *dev); struct s_cmds { const char *cmd; bool (*func)(JCR *jcr); - int monitoraccess; /* specify if monitors have access to this function */ + bool monitoraccess; /* set if monitors can access this cmd */ }; /* @@ -177,6 +175,7 @@ void *handle_connection_request(void *arg) if (sscanf(bs->msg, "Hello Start Job %127s", name) == 1) { Dmsg1(110, "Got a FD connection at %s\n", bstrftimes(tbuf, sizeof(tbuf), (utime_t)time(NULL))); + Dmsg1(50, "%s", bs->msg); handle_filed_connection(bs, name); return NULL; } @@ -388,7 +387,7 @@ static bool do_label(JCR *jcr, int relabel) if (dcr) { dev = dcr->dev; dev->dlock(); /* Use P to avoid indefinite block */ - if (!dev->is_open()) { + if (!dev->is_open() && !dev->is_busy()) { Dmsg1(400, "Can %slabel. Device is not open\n", relabel?"re":""); label_volume_if_ok(dcr, oldname, newname, poolname, slot, relabel); dev->close(); @@ -652,7 +651,8 @@ static bool mount_cmd(JCR *jcr) if (dcr) { dev = dcr->dev; dev->dlock(); /* Use P to avoid indefinite block */ - Dmsg1(100, "mount cmd blocked=%d\n", dev->blocked()); + Dmsg2(100, "mount cmd blocked=%d must_unload=%d\n", dev->blocked(), + dev->must_unload()); switch (dev->blocked()) { /* device blocked? */ case BST_WAITING_FOR_SYSOP: /* Someone is waiting, wake him */ @@ -673,8 +673,8 @@ static bool mount_cmd(JCR *jcr) } /* We freed the device, so reopen it and wake any waiting threads */ if (dev->open(dcr, OPEN_READ_ONLY) < 0) { - dir->fsend(_("3901 open device failed: ERR=%s\n"), - dev->bstrerror()); + dir->fsend(_("3901 Unable to open device %s: ERR=%s\n"), + dev->print_name(), dev->bstrerror()); if (dev->blocked() == BST_UNMOUNTED) { /* We blocked the device, so unblock it */ Dmsg0(100, "Unmounted. Unblocking device\n"); @@ -730,8 +730,8 @@ static bool mount_cmd(JCR *jcr) } } else if (dev->is_tape()) { if (dev->open(dcr, OPEN_READ_ONLY) < 0) { - dir->fsend(_("3901 open device failed: ERR=%s\n"), - dev->bstrerror()); + dir->fsend(_("3901 Unable to open device %s: ERR=%s\n"), + dev->print_name(), dev->bstrerror()); break; } read_label(dcr); @@ -839,7 +839,7 @@ static bool unmount_cmd(JCR *jcr) */ /* block_device(dev, BST_UNMOUNTED); replace with 2 lines below */ dev->set_blocked(BST_UNMOUNTED); - dev->no_wait_id = 0; + clear_thread_id(dev->no_wait_id); if (!unload_autochanger(dcr, -1)) { dev->close(); } @@ -917,7 +917,6 @@ static bool release_cmd(JCR *jcr) send_dir_busy_message(dir, dev); } else { /* device not being used */ Dmsg0(90, "Device not in use, releasing\n"); - unload_autochanger(dcr, -1); dcr->release_volume(); dir->fsend(_("3022 Device %s released.\n"), dev->print_name()); @@ -939,6 +938,10 @@ static bool release_cmd(JCR *jcr) static bool bootstrap_cmd(JCR *jcr) { + /* If getting the bootstrap file succeeds, we do not need + * the FD because we will be reading. + */ + jcr->need_fd = false; return get_bootstrap_file(jcr, jcr->dir_bsock); }