Fix a deadlock in last commit

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13754 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Darren Schreiber 2009-06-11 03:42:01 +00:00
parent 99fb025748
commit 2ff2a18b61
1 changed files with 16 additions and 19 deletions

View File

@ -430,10 +430,6 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Comparing %f to hangup
/* Not enough money - reroute call to nobal location */ /* Not enough money - reroute call to nobal location */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Balance of %f fell below allowed amount of %f! (Account %s)\n", balance, globals.nobal_amt, billaccount); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Balance of %f fell below allowed amount of %f! (Account %s)\n", balance, globals.nobal_amt, billaccount);
/* IMPORTANT: Billing must be paused before the transfer occurs! This prevents infinite loops, since the transfer will result */
/* in nibblebill checking the call again in the routing process for an allowed balance! */
/* If you intend to give the user the option to re-up their balance, you must clear & resume billing once the balance is updated! */
nibblebill_pause(session);
transfer_call(session, globals.nobal_action); transfer_call(session, globals.nobal_action);
} }
@ -503,22 +499,23 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Comparing %f to hangup
/* Save this location, but only if the channel/session are not hungup (otherwise, we're done) */ /* Save this location, but only if the channel/session are not hungup (otherwise, we're done) */
if (channel && switch_channel_get_state(channel) != CS_HANGUP) { if (channel && switch_channel_get_state(channel) != CS_HANGUP) {
switch_channel_set_private(channel, "_nibble_data_", nibble_data); switch_channel_set_private(channel, "_nibble_data_", nibble_data);
float balance;
/* See if this person has enough money left to continue the call */
balance = get_balance(billaccount);
if (balance <= globals.nobal_amt) {
/* Not enough money - reroute call to nobal location */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Balance of %f fell below allowed amount of %f! (Account %s)\n", balance, globals.nobal_amt, billaccount);
/* IMPORTANT: Billing must be paused before the transfer occurs! This prevents infinite loops, since the transfer will result */
/* in nibblebill checking the call again in the routing process for an allowed balance! */
/* If you intend to give the user the option to re-up their balance, you must clear & resume billing once the balance is updated! */
nibblebill_pause(session);
transfer_call(session, globals.nobal_action);
}
} }
float balance;
/* See if this person has enough money left to continue the call */
balance = get_balance(billaccount);
if (balance <= globals.nobal_amt) {
/* Not enough money - reroute call to nobal location */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Balance of %f fell below allowed amount of %f! (Account %s)\n", balance, globals.nobal_amt, billaccount);
/* IMPORTANT: Billing must be paused before the transfer occurs! This prevents infinite loops, since the transfer will result */
/* in nibblebill checking the call again in the routing process for an allowed balance! */
/* If you intend to give the user the option to re-up their balance, you must clear & resume billing once the balance is updated! */
nibblebill_pause(session);
transfer_call(session, globals.nobal_action);
}
/* Done changing - release lock */ /* Done changing - release lock */
if (globals.mutex) { if (globals.mutex) {
@ -840,7 +837,7 @@ switch_state_handler_table_t nibble_state_handler =
/* on_routing */ process_hangup, /* Need to add a check here for anything in their account before routing */ /* on_routing */ process_hangup, /* Need to add a check here for anything in their account before routing */
/* on_execute */ sched_billing, /* Turn on heartbeat for this session and do an initial account check */ /* on_execute */ sched_billing, /* Turn on heartbeat for this session and do an initial account check */
/* on_hangup */ process_hangup, /* On hangup - most important place to go bill */ /* on_hangup */ process_hangup, /* On hangup - most important place to go bill */
/* on_exch_media */ NULL, /* on_exch_media */ sched_billing,
/* on_soft_exec */ NULL, /* on_soft_exec */ NULL,
/* on_consume_med */ NULL, /* on_consume_med */ NULL,
/* on_hibernate */ NULL, /* on_hibernate */ NULL,