[asterisk-commits] mjordan: trunk r375730 - in /trunk: ./ main/cdr.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Nov 3 19:02:09 CDT 2012


Author: mjordan
Date: Sat Nov  3 19:02:06 2012
New Revision: 375730

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

Merged revisions 375729 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/main/cdr.c

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

Modified: trunk/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cdr.c?view=diff&rev=375730&r1=375729&r2=375730
==============================================================================
--- trunk/main/cdr.c (original)
+++ trunk/main/cdr.c Sat Nov  3 19:02:06 2012
@@ -1424,11 +1424,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