]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/job.c
Move reservations message lock to lock jcr only this
[bacula/bacula] / bacula / src / stored / job.c
index 6002e45d41596136e4992952b701826dddb132a7..8215000b83d5eb756a89e38062457dd4249e665d 100644 (file)
@@ -1,22 +1,14 @@
-/*
- *   Job control and execution for Storage Daemon
- *
- *   Kern Sibbald, MM
- *
- *   Version $Id$
- *
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 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
-   License as published by the Free Software Foundation plus additions
-   that are listed in the file LICENSE.
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
 
    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *   Job control and execution for Storage Daemon
+ *
+ *   Kern Sibbald, MM
+ *
+ *   Version $Id$
+ *
+ */
 
 #include "bacula.h"
 #include "stored.h"
@@ -150,6 +150,7 @@ bool run_cmd(JCR *jcr)
    struct timespec timeout;
    int errstat;
 
+   Dsm_check(1);
    Dmsg1(200, "Run_cmd: %s\n", jcr->dir_bsock->msg);
    /* The following jobs don't need the FD */
    switch (jcr->JobType) {
@@ -166,9 +167,10 @@ bool run_cmd(JCR *jcr)
 
    gettimeofday(&tv, &tz);
    timeout.tv_nsec = tv.tv_usec * 1000;
-   timeout.tv_sec = tv.tv_sec + 30 * 60;        /* wait 30 minutes */
+   timeout.tv_sec = tv.tv_sec + me->client_wait;
 
-   Dmsg1(100, "%s waiting on FD to contact SD\n", jcr->Job);
+   Dmsg2(100, "%s waiting %d sec for FD to contact SD\n", 
+        jcr->Job, (int)me->client_wait);
    /*
     * Wait for the File daemon to contact us to start the Job,
     *  when he does, we will be released, unless the 30 minutes
@@ -208,7 +210,7 @@ void handle_filed_connection(BSOCK *fd, char *job_name)
    }
 
    jcr->file_bsock = fd;
-   jcr->file_bsock->jcr = jcr;
+   jcr->file_bsock->set_jcr(jcr);
 
    Dmsg1(110, "Found Job %s\n", job_name);
 
@@ -353,6 +355,11 @@ void stored_free_jcr(JCR *jcr)
       delete jcr->dcrs;
    }
    jcr->dcrs = NULL;
+
+   /* Avoid a double free */
+   if (jcr->dcr == jcr->read_dcr) {
+      jcr->read_dcr = NULL;
+   }
    if (jcr->dcr) {
       free_dcr(jcr->dcr);
       jcr->dcr = NULL;
@@ -380,6 +387,6 @@ void stored_free_jcr(JCR *jcr)
       delete jcr->write_store;
       jcr->write_store = NULL;
    }
-
+   Dsm_check(1);
    return;
 }