]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/dircmd.c
Make third argument of DEVICE::d_ioctl optionnal to emulate varg
[bacula/bacula] / bacula / src / stored / dircmd.c
index 8cf6ac8d09ff80430faac067e5de063072824c97..5664144fb8e018e3e94061c57b6c80229347c0d1 100644 (file)
@@ -1,12 +1,12 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2001-2009 Free Software Foundation Europe e.V.
+   Copyright (C) 2001-2010 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    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
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -43,8 +43,6 @@
  *
  *     Kern Sibbald, May MMI
  *
- *   Version $Id$
- *
  */
 
 #include "bacula.h"
@@ -58,7 +56,7 @@ extern struct s_last_job last_job;
 extern bool init_done;
 
 /* Static variables */
-static char derrmsg[]     = "3900 Invalid command\n";
+static char derrmsg[]     = "3900 Invalid command:";
 static char OKsetdebug[]  = "3000 OK setdebug=%d\n";
 static char invalid_cmd[] = "3997 Invalid command for a Director with Monitor directive enabled.\n";
 static char OK_bootstrap[]    = "3000 OK bootstrap\n";
@@ -234,14 +232,16 @@ void *handle_connection_request(void *arg)
            Dmsg1(200, "Do command: %s\n", cmds[i].cmd);
            if (!cmds[i].func(jcr)) { /* do command */
               quit = true; /* error, get out */
-              Dmsg1(190, "Command %s reqeusts quit\n", cmds[i].cmd);
+              Dmsg1(190, "Command %s requests quit\n", cmds[i].cmd);
            }
            found = true;             /* indicate command found */
            break;
         }
       }
       if (!found) {                   /* command not found */
-        bs->fsend(derrmsg);
+        POOL_MEM err_msg;
+        Mmsg(err_msg, "%s %s\n", derrmsg, bs->msg);
+        bs->fsend(err_msg.c_str());
         break;
       }
    }
@@ -263,7 +263,16 @@ static bool die_cmd(JCR *jcr)
 #ifdef DEVELOPER
    JCR *djcr = NULL;
    int a;
-   Pmsg0(000, "I have been requested to die ...");
+   BSOCK *dir = jcr->dir_bsock;
+   pthread_mutex_t m=PTHREAD_MUTEX_INITIALIZER;
+
+   if (strstr(dir->msg, "deadlock")) {
+      Pmsg0(000, "I have been requested to deadlock ...\n");
+      P(m);
+      P(m);
+   }
+   
+   Pmsg1(000, "I have been requested to die ... (%s)\n", dir->msg);
    a = djcr->JobId;   /* ref NULL pointer */
 #endif
    return 0;
@@ -307,14 +316,18 @@ static bool cancel_cmd(JCR *cjcr)
       } else {
          oldStatus = jcr->JobStatus;
          set_jcr_job_status(jcr, JS_Canceled);
+         Dmsg2(800, "Cancel JobId=%d %p\n", jcr->JobId, jcr);
          if (!jcr->authenticated && oldStatus == JS_WaitFD) {
             pthread_cond_signal(&jcr->job_start_wait); /* wake waiting thread */
          }
          if (jcr->file_bsock) {
-            bnet_sig(jcr->file_bsock, BNET_TERMINATE);
+            jcr->file_bsock->signal(BNET_TERMINATE);
+            jcr->file_bsock->set_terminated();
+            Dmsg2(800, "Term bsock jid=%d %p\n", jcr->JobId, jcr);
          } else {
             /* Still waiting for FD to connect, release it */
             pthread_cond_signal(&jcr->job_start_wait); /* wake waiting job */
+            Dmsg2(800, "Signal FD connect jid=%d %p\n", jcr->JobId, jcr);
          }
          /* If thread waiting on mount, wake him */
          if (jcr->dcr && jcr->dcr->dev && jcr->dcr->dev->waiting_for_mount()) {
@@ -462,7 +475,7 @@ static void label_volume_if_ok(DCR *dcr, char *oldname,
       dev->truncating = true;         /* let open() know we will truncate it */
    }
    /* Set old volume name for open if relabeling */
-   bstrncpy(dcr->VolCatInfo.VolCatName, volname, sizeof(dcr->VolCatInfo.VolCatName));
+   dcr->setVolCatName(volname);
    if (dev->open(dcr, mode) < 0) {
       dir->fsend(_("3910 Unable to open device %s: ERR=%s\n"),
          dev->print_name(), dev->bstrerror());
@@ -473,7 +486,7 @@ static void label_volume_if_ok(DCR *dcr, char *oldname,
    label_status = read_dev_volume_label(dcr);
    
    /* Set new volume name */
-   bstrncpy(dcr->VolCatInfo.VolCatName, newname, sizeof(dcr->VolCatInfo.VolCatName));
+   dcr->setVolCatName(newname);
    switch(label_status) {
    case VOL_NAME_ERROR:
    case VOL_VERSION_ERROR: