From: Kern Sibbald Date: Tue, 18 Apr 2006 10:20:35 +0000 (+0000) Subject: - Remove the -f option from the chown in Makefile.in for more X-Git-Tag: Release-7.0.0~8057 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3437805e9bd06253e1ac27069f9321bd5d4f38c3;p=bacula%2Fbacula - 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. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2939 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/Makefile.in b/bacula/Makefile.in index 24bedb6b07..00a3e5c6a9 100755 --- a/bacula/Makefile.in +++ b/bacula/Makefile.in @@ -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) diff --git a/bacula/kes-1.39 b/bacula/kes-1.39 index 3802437e5b..4a23fde8ca 100644 --- a/bacula/kes-1.39 +++ b/bacula/kes-1.39 @@ -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. diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index 46adb0c1a7..207bf9f360 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -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); diff --git a/bacula/src/dird/pythondir.c b/bacula/src/dird/pythondir.c index 57557fbfaa..9f5df846c0 100644 --- a/bacula/src/dird/pythondir.c +++ b/bacula/src/dird/pythondir.c @@ -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; } diff --git a/bacula/src/filed/Makefile.in b/bacula/src/filed/Makefile.in index c0e86adb7f..8b73c5e6ce 100755 --- a/bacula/src/filed/Makefile.in +++ b/bacula/src/filed/Makefile.in @@ -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) diff --git a/bacula/src/filed/pythonfd.c b/bacula/src/filed/pythonfd.c index 68c3b5397b..0198eeaced 100644 --- a/bacula/src/filed/pythonfd.c +++ b/bacula/src/filed/pythonfd.c @@ -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; } diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 86b2426ca6..a4d9a85645 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -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 */ diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 1361b37541..7cdd8eeb1a 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -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)); diff --git a/bacula/src/lib/pythonlib.c b/bacula/src/lib/pythonlib.c index 34d738a6cf..cc432cfdc9 100644 --- a/bacula/src/lib/pythonlib.c +++ b/bacula/src/lib/pythonlib.c @@ -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 @@ -30,6 +30,12 @@ #undef _POSIX_C_SOURCE #include +/* 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 /* diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index b9fa039c6f..28629c3b51 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -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; } diff --git a/bacula/src/stored/pythonsd.c b/bacula/src/stored/pythonsd.c index b728de9402..e481cdd7c5 100644 --- a/bacula/src/stored/pythonsd.c +++ b/bacula/src/stored/pythonsd.c @@ -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; } diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 1859001811..d10c0c0427 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -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, "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; diff --git a/bacula/src/stored/reserve.h b/bacula/src/stored/reserve.h index 38e77dbdc8..c4f8028ce6 100644 --- a/bacula/src/stored/reserve.h +++ b/bacula/src/stored/reserve.h @@ -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 */ }; diff --git a/bacula/src/version.h b/bacula/src/version.h index 7c2a5bad98..00f6740a6a 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -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