1
0
mirror of https://github.com/signalwire/freeswitch.git synced 2025-04-02 03:14:59 +00:00

Fix counter bug

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10881 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Mathieu Rene 2008-12-19 04:11:51 +00:00
parent bab48c729e
commit dd3c813e11

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