[svn-commits] russell: trunk r38587 - /trunk/channels/iax2-parser.c
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Mon Jul 31 10:27:42 MST 2006
Author: russell
Date: Mon Jul 31 12:27:42 2006
New Revision: 38587
URL: http://svn.digium.com/view/asterisk?rev=38587&view=rev
Log:
make the counting of ingress, outgress, and total frames thread-safe
Modified:
trunk/channels/iax2-parser.c
Modified: trunk/channels/iax2-parser.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/iax2-parser.c?rev=38587&r1=38586&r2=38587&view=diff
==============================================================================
--- trunk/channels/iax2-parser.c (original)
+++ trunk/channels/iax2-parser.c Mon Jul 31 12:27:42 2006
@@ -39,6 +39,8 @@
#include "asterisk/frame.h"
#include "asterisk/utils.h"
#include "asterisk/unaligned.h"
+#include "asterisk/lock.h"
+
#include "iax2.h"
#include "iax2-parser.h"
#include "iax2-provision.h"
@@ -929,11 +931,11 @@
if (fr) {
fr->direction = direction;
fr->retrans = -1;
- frames++;
+ ast_atomic_fetchadd_int(&frames, 1);
if (fr->direction == DIRECTION_INGRESS)
- iframes++;
+ ast_atomic_fetchadd_int(&iframes, 1);
else
- oframes++;
+ ast_atomic_fetchadd_int(&oframes, 1);
}
return fr;
}
@@ -942,16 +944,16 @@
{
/* Note: does not remove from scheduler! */
if (fr->direction == DIRECTION_INGRESS)
- iframes--;
+ ast_atomic_fetchadd_int(&iframes, -1);
else if (fr->direction == DIRECTION_OUTGRESS)
- oframes--;
+ ast_atomic_fetchadd_int(&oframes, -1);
else {
errorf("Attempt to double free frame detected\n");
return;
}
fr->direction = 0;
free(fr);
- frames--;
+ ast_atomic_fetchadd_int(&frames, -1);
}
int iax_get_frames(void) { return frames; }
More information about the svn-commits
mailing list