[Freeswitch-svn] [commit] r10881 - freeswitch/trunk/src/mod/applications/mod_limit

FreeSWITCH SVN mrene at freeswitch.org
Thu Dec 18 20:11:52 PST 2008


Author: mrene
Date: Thu Dec 18 23:11:51 2008
New Revision: 10881

Log:
Fix counter bug

Modified:
   freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c

Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c	Thu Dec 18 23:11:51 2008
@@ -816,14 +816,11 @@
 	/* Did we already run on this channel before? */
 	if ((channel_hash = switch_channel_get_private(channel, "limit_hash")))
 	{
-		/* Yes, but check if we did that realm+id */
-		if (!switch_core_hash_find(channel_hash, hashkey)) {
-			/* No, add it to our table so the state handler can take care of it */
-			switch_core_hash_insert(channel_hash, hashkey, item);
-		} else {
-			/* Yes, dont touch total counter */
-			increment = 0;
-		}
+		/* Yes, but check if we did that realm+id
+		   If we didnt, allow incrementing the counter.
+		   If we did, dont touch it but do the validation anyways
+		 */
+		increment = !!!switch_core_hash_find(channel_hash, hashkey);
 	} else {
 		/* This is the first limit check on this channel, create a hashtable, set our prviate data and add a state handler */
 		new_channel = 1;
@@ -852,6 +849,10 @@
 	if (increment) {
 		item->total_usage++;
 		
+		if (!new_channel)  {
+			switch_core_hash_insert(channel_hash, hashkey, item);
+		}
+		
 		if (interval == 0) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Usage for %s is now %d/%d\n", hashkey, item->total_usage, max);	
 		} else {



More information about the Freeswitch-svn mailing list