]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/stored.c
Remove broken run when code
[bacula/bacula] / bacula / src / stored / stored.c
index aa6c47ad07c7f319bb329f92920507264bdb531f..e027ffd89d49e9ddfb5c741afd74d5f294db5444 100644 (file)
@@ -1,6 +1,35 @@
+/*
+   Bacula® - The Network Backup Solution
+
+   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.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   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
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
 /*
  * Second generation Storage daemon.
  *
+ *  Kern Sibbald, MM
+ *
  * It accepts a number of simple commands from the File daemon
  * and acts on them. When a request to append data is made,
  * it opens a data channel and accepts data from the
@@ -9,20 +38,6 @@
  *   Version $Id$
  *
  */
-/*
-   Copyright (C) 2000-2006 Kern Sibbald
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License
-   version 2 as amended with additional clauses defined in the
-   file LICENSE in the main source directory.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
-   the file LICENSE for additional details.
-
- */
 
 #include "bacula.h"
 #include "stored.h"
@@ -46,6 +61,7 @@ STORES *me = NULL;                    /* our Global resource */
 bool forge_on = false;                /* proceed inspite of I/O errors */
 pthread_mutex_t device_release_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_cond_t wait_device_release = PTHREAD_COND_INITIALIZER;
+void *start_heap;
 
 
 static uint32_t VolSessionId = 0;
@@ -62,7 +78,7 @@ static workq_t dird_workq;            /* queue for processing connections */
 static void usage()
 {
    fprintf(stderr, _(
-"Copyright (C) 2000-%s Kern Sibbald.\n"
+PROG_COPYRIGHT
 "\nVersion: %s (%s)\n\n"
 "Usage: stored [options] [-c config_file] [config_file]\n"
 "        -c <file>   use <file> as configuration file\n"
@@ -75,7 +91,7 @@ static void usage()
 "        -u <user>   userid to <user>\n"
 "        -v          verbose user messages\n"
 "        -?          print this message.\n"
-"\n"), BYEAR, VERSION, BDATE);
+"\n"), 2000, VERSION, BDATE);
    exit(1);
 }
 
@@ -97,6 +113,7 @@ int main (int argc, char *argv[])
    char *uid = NULL;
    char *gid = NULL;
 
+   start_heap = sbrk(0);
    setlocale(LC_ALL, "");
    bindtextdomain("bacula", LOCALEDIR);
    textdomain("bacula");
@@ -424,11 +441,7 @@ static void cleanup_old_files()
    pm_strcpy(cleanup, "/bin/rm -f ");
 #endif
    pm_strcat(cleanup, me->working_directory);
-   if (len > 0 && me->working_directory[len-1] != '/'
-#if defined(HAVE_WIN32)
-       && me->working_directory[len-1] != '\\'
-#endif
-       ) {
+   if (len > 0 && !IsPathSeparator(me->working_directory[len-1])) {
       pm_strcat(cleanup, "/");
    }
    pm_strcat(cleanup, my_name);
@@ -499,6 +512,13 @@ void *device_initialization(void *arg)
       free_dcr(dcr);
       jcr->dcr = NULL;
    }
+#ifdef xxx
+   if (jcr->dcr) {
+      Dmsg1(000, "free_dcr=%p\n", jcr->dcr);
+      free_dcr(jcr->dcr);
+      jcr->dcr = NULL;
+   }
+#endif
    free_jcr(jcr); 
    init_done = true;
    UnlockRes();
@@ -538,11 +558,12 @@ void terminate_stored(int sig)
             Dmsg1(100, "term_stored killing JobId=%d\n", jcr->JobId);
             pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL);
             /* ***FIXME*** wiffle through all dcrs */
-            if (jcr->dcr && jcr->dcr->dev && jcr->dcr->dev->dev_blocked) {
+            if (jcr->dcr && jcr->dcr->dev && jcr->dcr->dev->blocked()) {
                pthread_cond_broadcast(&jcr->dcr->dev->wait_next_vol);
+               Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)jcr->JobId);
                pthread_cond_broadcast(&wait_device_release);
             }
-            if (jcr->read_dcr && jcr->read_dcr->dev && jcr->read_dcr->dev->dev_blocked) {
+            if (jcr->read_dcr && jcr->read_dcr->dev && jcr->read_dcr->dev->blocked()) {
                pthread_cond_broadcast(&jcr->read_dcr->dev->wait_next_vol);
                pthread_cond_broadcast(&wait_device_release);
             }
@@ -561,7 +582,7 @@ void terminate_stored(int sig)
    foreach_res(device, R_DEVICE) {
       Dmsg1(10, "Term device %s\n", device->device_name);
       if (device->dev) {
-         free_volume(device->dev);
+         device->dev->clear_volhdr();
          device->dev->term();
          device->dev = NULL;
       } else {