[asterisk-commits] mjordan: branch 1.8 r375727 - /branches/1.8/main/cdr.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Nov 3 18:44:34 CDT 2012
Author: mjordan
Date: Sat Nov 3 18:44:30 2012
New Revision: 375727
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=375727
Log:
Prevent multiple CDR batches from conflicting when scheduling the CDR write
The Asterisk Test Suite caught an error condition where a scheduled CDR batch
write can be deleted twice if two channels attempt to post their CDRs at the
same time. The batch CDR mutex is locked while the CDRs are appended to the
current batch list; however, it is unlocked prior to actually scheduling the
CDR write. As such, two threads can attempt to remove the currently scheduled
batch write at the same time, resulting in an assertion error.
This patch extends the time that the mutex is locked to encompass actually
scheduling the write. This prevents two threads from unscheduling the
currently scheduled write at the same time.
Modified:
branches/1.8/main/cdr.c
Modified: branches/1.8/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/cdr.c?view=diff&rev=375727&r1=375726&r2=375727
==============================================================================
--- branches/1.8/main/cdr.c (original)
+++ branches/1.8/main/cdr.c Sat Nov 3 18:44:30 2012
@@ -1364,11 +1364,13 @@
newtail->cdr = cdr;
batch->tail = newtail;
curr = batch->size++;
+
+ /* if we have enough stuff to post, then do it */
+ if (curr >= (batchsize - 1)) {
+ submit_unscheduled_batch();
+ }
+
ast_mutex_unlock(&cdr_batch_lock);
-
- /* if we have enough stuff to post, then do it */
- if (curr >= (batchsize - 1))
- submit_unscheduled_batch();
}
static void *do_cdr(void *data)
More information about the asterisk-commits
mailing list