From: Kern Sibbald Date: Tue, 26 Jun 2007 16:06:13 +0000 (+0000) Subject: Move reservations message lock to lock jcr only this X-Git-Tag: Release-7.0.0~6065 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=af39018cdc87c531903ea9a645c5c91d42bba08a;p=bacula%2Fbacula Move reservations message lock to lock jcr only this fixes bug #861. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5103 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 787ad34316..de2732daf8 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -788,22 +788,6 @@ static bool use_storage_cmd(JCR *jcr) return ok; } -void release_msgs(JCR *jcr) -{ - alist *msgs = jcr->reserve_msgs; - char *msg; - - if (!msgs) { - return; - } - lock_reservations(); - while ((msg = (char *)msgs->pop())) { - free(msg); - } - delete msgs; - jcr->reserve_msgs = NULL; - unlock_reservations(); -} /* * Walk through the autochanger resources and check if @@ -1471,17 +1455,23 @@ static int can_reserve_drive(DCR *dcr, RCTX &rctx) return 0; } + + + /* - * search_lock is already set on entering this routine + * Queue a reservation error or failure message for this jcr */ static void queue_reserve_message(JCR *jcr) { int i; - alist *msgs = jcr->reserve_msgs; + alist *msgs; char *msg; + jcr->lock(); + + msgs = jcr->reserve_msgs; if (!msgs) { - return; + goto bail_out; } /* * Look for duplicate message. If found, do @@ -1490,7 +1480,7 @@ static void queue_reserve_message(JCR *jcr) for (i=msgs->size()-1; i >= 0; i--) { msg = (char *)msgs->get(i); if (!msg) { - return; + goto bail_out; } /* Comparison based on 4 digit message number */ if (strncmp(msg, jcr->errmsg, 4) == 0) { @@ -1499,6 +1489,9 @@ static void queue_reserve_message(JCR *jcr) } /* Message unique, so insert it */ jcr->reserve_msgs->push(bstrdup(jcr->errmsg)); + +bail_out: + jcr->unlock(); } /* @@ -1510,7 +1503,7 @@ void send_drive_reserve_messages(JCR *jcr, void sendit(const char *msg, int len, alist *msgs; char *msg; - lock_reservations(); + jcr->lock(); msgs = jcr->reserve_msgs; if (!msgs || msgs->size() == 0) { goto bail_out; @@ -1526,5 +1519,25 @@ void send_drive_reserve_messages(JCR *jcr, void sendit(const char *msg, int len, } bail_out: - unlock_reservations(); + jcr->unlock(); +} + +void release_msgs(JCR *jcr) +{ + alist *msgs; + char *msg; + + jcr->lock(); + msgs = jcr->reserve_msgs; + if (!msgs) { + goto bail_out; + } + while ((msg = (char *)msgs->pop())) { + free(msg); + } + delete msgs; + jcr->reserve_msgs = NULL; + +bail_out: + jcr->unlock(); } diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index 8426d3bd1a..f58fd1356d 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -3,6 +3,8 @@ General: 26Jun07 +kes Move reservations message lock to lock jcr only this + fixes bug #861. kes Move main SD locking code into lock.c (new file). kes Update Win32 build to include lock.c