]> git.sur5r.net Git - bacula/bacula/commitdiff
- Remove the -f option from the chown in Makefile.in for more
authorKern Sibbald <kern@sibbald.com>
Tue, 18 Apr 2006 10:20:35 +0000 (10:20 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 18 Apr 2006 10:20:35 +0000 (10:20 +0000)
  portability.
- Change setting the group in Makefile.in to use chgrp for
  more portability.
- Implement a write_store and read_store to replace
  dirstore in reserve.c
- Implement a Bacula read/write lock for Python rather
  than using the Python lock to avoid recursive problems.
- Correct the uninstall directory names in filed/Makefile.in
  as reported by a user.

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

14 files changed:
bacula/Makefile.in
bacula/kes-1.39
bacula/src/dird/migrate.c
bacula/src/dird/pythondir.c
bacula/src/filed/Makefile.in
bacula/src/filed/pythonfd.c
bacula/src/jcr.h
bacula/src/lib/protos.h
bacula/src/lib/pythonlib.c
bacula/src/stored/job.c
bacula/src/stored/pythonsd.c
bacula/src/stored/reserve.c
bacula/src/stored/reserve.h
bacula/src/version.h

index 24bedb6b073be0980c5ec7f012f155ebb791a805..00a3e5c6a9d1e18470457a275e93be86fda3a1ab 100755 (executable)
@@ -94,10 +94,10 @@ installdirs:
           chmod 770 $(DESTDIR)$(working_dir); \
        fi
        -if test "x$(dir_user)" != "x" ; then \
-          chown -f $(dir_user) $(DESTDIR)$(working_dir); \
+          chown $(dir_user) $(DESTDIR)$(working_dir); \
        fi
        -if test "x$(dir_group)" != "x" ; then \
-          chown -f :$(dir_group) $(DESTDIR)$(working_dir); \
+          chgrp $(dir_group) $(DESTDIR)$(working_dir); \
        fi
 #      $(MKDIR) $(DESTDIR)$(mandir)
 
index 3802437e5b0ebc52136577d1466d7a4c2b0478ad..4a23fde8ca2c4a6fbb8e55437816709fcb1c3a07 100644 (file)
@@ -2,6 +2,17 @@
                         Kern Sibbald
 
 General:
+18Apr06
+- Remove the -f option from the chown in Makefile.in for more
+  portability.
+- Change setting the group in Makefile.in to use chgrp for
+  more portability.
+- Implement a write_store and read_store to replace
+  dirstore in reserve.c
+- Implement a Bacula read/write lock for Python rather
+  than using the Python lock to avoid recursive problems.
+- Correct the uninstall directory names in filed/Makefile.in
+  as reported by a user.
 17Apr06
 - Correct some problems with database creation (new tables).
 - Replace a bunch of old 0x%x by %p.
index 46adb0c1a70a0cdd2c45bf30d542287b9b28386b..207bf9f3600aa7f43e3d070c06bed69a728c02e8 100644 (file)
@@ -449,8 +449,8 @@ static bool get_job_to_migrate(JCR *jcr)
             const int nmatch = 30;
             regmatch_t pmatch[nmatch];
             if (last_item) {
-               free(last_item->item);
                Dmsg1(000, "Remove item %s\n", last_item->item);
+               free(last_item->item);
                item_chain->remove(last_item);
             }
             Dmsg1(000, "Jobitem=%s\n", item->item);
index 57557fbfaacbebbd040fdee4ec7f2df4725b7934..9f5df846c0326d169be6012fbc2ac04da3cde8ef 100644 (file)
@@ -297,7 +297,7 @@ static PyObject *job_run(PyObject *self, PyObject *arg)
       return NULL;
    }
    /* Release lock due to recursion */
-   PyEval_ReleaseLock();
+// PyEval_ReleaseLock();
    jcr = get_jcr_from_PyObject(self);
    UAContext *ua = new_ua_context(jcr);
    ua->batch = true;
@@ -305,7 +305,7 @@ static PyObject *job_run(PyObject *self, PyObject *arg)
    parse_ua_args(ua);                 /* parse command */
    stat = run_cmd(ua, ua->cmd);
    free_ua_context(ua);
-   PyEval_AcquireLock();
+// PyEval_AcquireLock();
    return PyInt_FromLong((long)stat);
 }
 
@@ -372,7 +372,7 @@ static PyObject *job_cancel(PyObject *self, PyObject *args)
       /* ***FIXME*** raise exception */
       return NULL;
    }
-   PyEval_ReleaseLock();
+// PyEval_ReleaseLock();
    UAContext *ua = new_ua_context(jcr);
    ua->batch = true;
    if (!cancel_job(ua, jcr)) {
@@ -381,7 +381,7 @@ static PyObject *job_cancel(PyObject *self, PyObject *args)
    }
    free_ua_context(ua);
    free_jcr(jcr);
-   PyEval_AcquireLock();   
+// PyEval_AcquireLock();   
    Py_INCREF(Py_None);
    return Py_None;
 }
@@ -403,7 +403,8 @@ int generate_job_event(JCR *jcr, const char *event)
       return 0;
    }
 
-   PyEval_AcquireLock();
+   lock_python();
+// PyEval_AcquireLock();
 
    method = find_method(events, method, event);
    if (!method) {
@@ -424,7 +425,8 @@ int generate_job_event(JCR *jcr, const char *event)
    Py_XDECREF(result);
 
 bail_out:
-   PyEval_ReleaseLock();
+   unlock_python();
+// PyEval_ReleaseLock();
    return stat;
 }
 
index c0e86adb7fe5c766b598539e0c19ca6fe41e224a..8b73c5e6ce3bf296786b6ae955bf0e7284288e62 100755 (executable)
@@ -137,8 +137,8 @@ install: all
 
 uninstall:
        (cd $(DESTDIR)$(sbindir); $(RMF) bacula-fd)
-       (cd $(DESTDIR)$(sbindir); $(RMF) bacula-fd.conf)
-       (cd $(DESTDIR)$(sbindir); $(RMF) bacula-fd.conf.new)
+       (cd $(DESTDIR)$(sysconfdir); $(RMF) bacula-fd.conf)
+       (cd $(DESTDIR)$(sysconfdir); $(RMF) bacula-fd.conf.new)
 
 
 
index 68c3b5397b5379c9b0c875808a53744026406053..0198eeaced92b199ab82acfc69e643207728eeb1 100644 (file)
@@ -7,24 +7,18 @@
  *   Version $Id$
  *
  */
-
 /*
    Copyright (C) 2005-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 as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   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 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., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -247,7 +241,8 @@ int generate_job_event(JCR *jcr, const char *event)
       return 0;
    }
 
-   PyEval_AcquireLock();
+   lock_python();
+// PyEval_AcquireLock();
 
    method = find_method(events, method, event);
    if (!method) {
@@ -268,7 +263,8 @@ int generate_job_event(JCR *jcr, const char *event)
    Py_XDECREF(result);
 
 bail_out:
-   PyEval_ReleaseLock();
+   unlock_python();
+// PyEval_ReleaseLock();
    return stat;
 }
 
index 86b2426ca61801f46822ca067ffc4357ede55d88..a4d9a856451427a92004d942b046c52ff8a691b1 100644 (file)
@@ -292,7 +292,8 @@ public:
    bool spool_data;                   /* set to spool data */
    int CurVol;                        /* Current Volume count */
    DIRRES* director;                  /* Director resource */
-   alist *dirstore;                   /* list of storage devices sent by DIR */ 
+   alist *write_store;                /* list of write storage devices sent by DIR */ 
+   alist *read_store;                 /* list of read devices sent by DIR */
    alist *reserve_msgs;               /* reserve fail messages */
    bool write_part_after_job;         /* Set to write part after job */
    bool PreferMountedVols;            /* Prefer mounted vols rather than new */
index 1361b37541d40b27b57fd77b20656031e665ea20..7cdd8eeb1ae729ed627e8e4d1c4207bfd55900de 100644 (file)
@@ -222,6 +222,8 @@ void init_python_interpreter(const char *progname, const char *scripts,
 void term_python_interpreter();
 //extern EVENT_HANDLER *generate_daemon_event;
 int generate_daemon_event(JCR *jcr, const char *event);
+void lock_python();
+void unlock_python();
 
 /* signal.c */
 void             init_signals             (void terminate(int sig));
index 34d738a6cf9fb674f9a30fe6099a172b4a3c213d..cc432cfdc9d8198affb2de6a1d82bdcdc5da6da4 100644 (file)
@@ -8,7 +8,7 @@
  *
  */
 /*
-   Copyright (C) 2004-2005 Kern Sibbald
+   Copyright (C) 2004-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
 #undef _POSIX_C_SOURCE
 #include <Python.h>
 
+/* Forward referenced subroutines */
+static void init_python_lock();
+static void term_python_lock();
+void lock_python();
+void unlock_python();
+
 extern char *configfile;
 
 /* Imported subroutines */
@@ -135,6 +141,7 @@ void init_python_interpreter(const char *progname, const char *scripts,
       }
    }
    PyEval_ReleaseLock();
+   init_python_lock();
 }
 
 
@@ -144,6 +151,7 @@ void term_python_interpreter()
       Py_XDECREF(StartUp_module);
       Py_Finalize();
    }
+   term_python_lock();
 }
 
 static PyObject *set_bacula_events(PyObject *self, PyObject *args)
@@ -218,7 +226,8 @@ int generate_daemon_event(JCR *jcr, const char *event)
    }
 
    Dmsg1(100, "event=%s\n", event);
-   PyEval_AcquireLock();
+   lock_python();
+// PyEval_AcquireLock();
    if (strcmp(event, "JobStart") == 0) {
       if (!JobStart_method) {
          stat = 0;
@@ -292,10 +301,51 @@ bail_out:
    /* Fall through */
 jobstart_ok:
    Py_XDECREF(result);
-   PyEval_ReleaseLock();
+   unlock_python();
+// PyEval_ReleaseLock();
    return stat; 
 }
 
+static brwlock_t python_rwlock;
+
+static void init_python_lock()
+{
+   int errstat;
+   if ((errstat=rwl_init(&python_rwlock)) != 0) {
+      berrno be;
+      Emsg1(M_ABORT, 0, _("Unable to initialize the Python lock. ERR=%s\n"),
+            be.strerror(errstat));
+   }
+
+}
+
+static void term_python_lock()
+{
+   rwl_destroy(&python_rwlock);
+}
+
+/* This applies to a drive and to Volumes */
+void lock_python()
+{
+   int errstat;
+   if ((errstat=rwl_writelock(&python_rwlock)) != 0) {
+      berrno be;
+      Emsg2(M_ABORT, 0, "Python rwl_writelock failure. stat=%d: ERR=%s\n",
+           errstat, be.strerror(errstat));
+   }
+}
+
+void unlock_python()
+{
+   int errstat;
+   if ((errstat=rwl_writeunlock(&python_rwlock)) != 0) {
+      berrno be;
+      Emsg2(M_ABORT, 0, "Python rwl_writeunlock failure. stat=%d: ERR=%s\n",
+           errstat, be.strerror(errstat));
+   }
+}
+
+
 #else
 
 /*
index b9fa039c6fc3a63f3157f6fbb31262f00019b7de..28629c3b51e32b776d1149b206e4c1c112d81244 100644 (file)
@@ -305,6 +305,7 @@ bool query_cmd(JCR *jcr)
  */
 void stored_free_jcr(JCR *jcr)
 {
+   Dmsg1(900, "stored_free_jcr JobId=%u\n", jcr->JobId);
    if (jcr->file_bsock) {
       bnet_close(jcr->file_bsock);
       jcr->file_bsock = NULL;
@@ -347,14 +348,25 @@ void stored_free_jcr(JCR *jcr)
       free_dcr(jcr->read_dcr);
       jcr->read_dcr = NULL;
    }
-   if (jcr->dirstore) {
+
+   if (jcr->read_store) {
       DIRSTORE *store;
-      foreach_alist(store, jcr->dirstore) {
+      foreach_alist(store, jcr->read_store) {
          delete store->device;
          delete store;
       }
-      delete jcr->dirstore;
-      jcr->dirstore = NULL;
+      delete jcr->read_store;
+      jcr->read_store = NULL;
    }
+   if (jcr->write_store) {
+      DIRSTORE *store;
+      foreach_alist(store, jcr->write_store) {
+         delete store->device;
+         delete store;
+      }
+      delete jcr->write_store;
+      jcr->write_store = NULL;
+   }
+
    return;
 }
index b728de9402334279c4d96fe286d1881cf8dbc2cc..e481cdd7c5de74a089aeda1690cb3dd9de0347d8 100644 (file)
@@ -7,27 +7,22 @@
  *   Version $Id$
  *
  */
-
 /*
-   Copyright (C) 2005 Kern Sibbald
+   Copyright (C) 2005-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 as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   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 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., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
+
 #include "bacula.h"
 #include "stored.h"
 
@@ -238,7 +233,8 @@ int generate_job_event(JCR *jcr, const char *event)
       return 0;
    }
 
-   PyEval_AcquireLock();
+   lock_python();
+// PyEval_AcquireLock();
 
    method = find_method(events, method, event);
    if (!method) {
@@ -259,7 +255,8 @@ int generate_job_event(JCR *jcr, const char *event)
    Py_XDECREF(result);
 
 bail_out:
-   PyEval_ReleaseLock();
+   unlock_python();
+// PyEval_ReleaseLock();
    return stat;
 }
 
index 1859001811d71f83d6269eef9d0cf38acd600c92..d10c0c04271e2cbf24aa0f79302e449d1bec7980 100644 (file)
@@ -340,6 +340,7 @@ static bool use_storage_cmd(JCR *jcr)
    RCTX rctx;
    char *msg;
    alist *msgs;
+   alist *dirstore;
 
    memset(&rctx, 0, sizeof(RCTX));
    rctx.jcr = jcr;
@@ -347,7 +348,8 @@ static bool use_storage_cmd(JCR *jcr)
     * If there are multiple devices, the director sends us
     *   use_device for each device that it wants to use.
     */
-   jcr->dirstore = New(alist(10, not_owned_by_alist));
+   dirstore = New(alist(10, not_owned_by_alist));
+// Dmsg2(000, "dirstore=%p JobId=%u\n", dirstore, jcr->JobId);
    msgs = jcr->reserve_msgs = New(alist(10, not_owned_by_alist));  
    do {
       Dmsg1(100, "<dird: %s", dir->msg);
@@ -357,12 +359,18 @@ static bool use_storage_cmd(JCR *jcr)
       if (!ok) {
          break;
       }
+      if (append) {
+         jcr->write_store = dirstore;
+      } else {
+         jcr->read_store = dirstore;
+      }
+      rctx.append = append;
       unbash_spaces(store_name);
       unbash_spaces(media_type);
       unbash_spaces(pool_name);
       unbash_spaces(pool_type);
       store = new DIRSTORE;
-      jcr->dirstore->append(store);
+      dirstore->append(store);
       memset(store, 0, sizeof(DIRSTORE));
       store->device = New(alist(10));
       bstrncpy(store->name, store_name, sizeof(store->name));
@@ -387,7 +395,7 @@ static bool use_storage_cmd(JCR *jcr)
    /* This loop is debug code and can be removed */
    /* ***FIXME**** remove after 1.38 release */
    char *device_name;
-   foreach_alist(store, jcr->dirstore) {
+   foreach_alist(store, dirstore) {
       Dmsg5(110, "Storage=%s media_type=%s pool=%s pool_type=%s append=%d\n", 
          store->name, store->media_type, store->pool_name, 
          store->pool_type, store->append);
@@ -538,7 +546,13 @@ bool find_suitable_device_for_job(JCR *jcr, RCTX &rctx)
    bool ok;
    DIRSTORE *store;
    char *device_name;
+   alist *dirstore;
 
+   if (rctx.append) {
+      dirstore = jcr->write_store;
+   } else {
+      dirstore = jcr->read_store;
+   }
    /* 
     * For each storage device that the user specified, we
     *  search and see if there is a resource for that device.
@@ -547,7 +561,7 @@ bool find_suitable_device_for_job(JCR *jcr, RCTX &rctx)
       rctx.PreferMountedVols, rctx.exact_match, rctx.suitable_device,
       rctx.autochanger_only);
    ok = false;
-   foreach_alist(store, jcr->dirstore) {
+   foreach_alist(store, dirstore) {
       rctx.store = store;
       foreach_alist(device_name, store->device) {
          int stat;
index 38e77dbdc892f5e2700cec9f8d127232e731f8ca..c4f8028ce648537a2ad9d57a38e1ad19f3737699 100644 (file)
@@ -57,5 +57,6 @@ public:
    bool suitable_device;              /* at least one device is suitable */
    bool autochanger_only;             /* look at autochangers only */
    bool notify_dir;                   /* Notify DIR about device */
+   bool append;                       /* set if append device */
    char VolumeName[MAX_NAME_LENGTH];  /* Vol name suggested by DIR */
 };
index 7c2a5bad98cabc868cd6f568aadc67b0152ceef1..00f6740a6a424c75e6241c422a50c310cf625c92 100644 (file)
@@ -3,9 +3,9 @@
  */
 
 #undef  VERSION
-#define VERSION "1.39.8"
-#define BDATE   "16 April 2006"
-#define LSMDATE "16Apr06"
+#define VERSION "1.39.9"
+#define BDATE   "18 April 2006"
+#define LSMDATE "18Apr06"
 
 /* Debug flags */
 #undef  DEBUG