[asterisk-commits] mjordan: branch 11 r375729 - in /branches/11: ./ main/cdr.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Nov 3 18:52:57 CDT 2012


Author: mjordan
Date: Sat Nov  3 18:52:54 2012
New Revision: 375729

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=375729
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.
........

Merged revisions 375727 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 375728 from http://svn.asterisk.org/svn/asterisk/branches/10

Modified:
    branches/11/   (props changed)
    branches/11/main/cdr.c

Propchange: branches/11/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.

Modified: branches/11/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/cdr.c?view=diff&rev=375729&r1=375728&r2=375729
==============================================================================
--- branches/11/main/cdr.c (original)
+++ branches/11/main/cdr.c Sat Nov  3 18:52:54 2012
@@ -1413,11 +1413,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