From: <ke...@us...> - 2007-06-26 16:06:36
|
Revision: 5103 http://bacula.svn.sourceforge.net/bacula/?rev=5103&view=rev Author: kerns Date: 2007-06-26 09:06:13 -0700 (Tue, 26 Jun 2007) Log Message: ----------- Move reservations message lock to lock jcr only this fixes bug #861. Modified Paths: -------------- trunk/bacula/src/stored/reserve.c trunk/bacula/technotes-2.1 Modified: trunk/bacula/src/stored/reserve.c =================================================================== --- trunk/bacula/src/stored/reserve.c 2007-06-26 15:11:46 UTC (rev 5102) +++ trunk/bacula/src/stored/reserve.c 2007-06-26 16:06:13 UTC (rev 5103) @@ -788,23 +788,7 @@ 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 * the volume is in one of them. @@ -1471,17 +1455,23 @@ 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 @@ 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 @@ } /* Message unique, so insert it */ jcr->reserve_msgs->push(bstrdup(jcr->errmsg)); + +bail_out: + jcr->unlock(); } /* @@ -1510,7 +1503,7 @@ alist *msgs; char *msg; - lock_reservations(); + jcr->lock(); msgs = jcr->reserve_msgs; if (!msgs || msgs->size() == 0) { goto bail_out; @@ -1526,5 +1519,25 @@ } 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(); +} Modified: trunk/bacula/technotes-2.1 =================================================================== --- trunk/bacula/technotes-2.1 2007-06-26 15:11:46 UTC (rev 5102) +++ trunk/bacula/technotes-2.1 2007-06-26 16:06:13 UTC (rev 5103) @@ -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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |