fifo tweaks

This commit is contained in:
Anthony Minessale 2010-07-26 18:53:52 -05:00
parent 6bb5703e16
commit 54b768eede
1 changed files with 55 additions and 25 deletions

View File

@ -750,6 +750,8 @@ static switch_bool_t fifo_execute_sql_callback(switch_mutex_t *mutex, char *sql,
goto end; goto end;
} }
if (globals.debug > 1) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "sql: %s\n", sql);
switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &errmsg); switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &errmsg);
if (errmsg) { if (errmsg) {
@ -1749,6 +1751,7 @@ static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *o
for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) { for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
switch_hash_this(hi, &var, NULL, &val); switch_hash_this(hi, &var, NULL, &val);
if ((node = (fifo_node_t *) val)) { if ((node = (fifo_node_t *) val)) {
if (node->outbound_priority == 0) node->outbound_priority = 5;
if (node->has_outbound && node->ready && !node->busy && node->outbound_priority == cur_priority) { if (node->has_outbound && node->ready && !node->busy && node->outbound_priority == cur_priority) {
ppl_waiting = node_consumer_wait_count(node); ppl_waiting = node_consumer_wait_count(node);
consumer_total = node->consumer_count; consumer_total = node->consumer_count;
@ -2146,11 +2149,6 @@ SWITCH_STANDARD_APP(fifo_function)
const char *arg_inout = NULL; const char *arg_inout = NULL;
const char *serviced_uuid = NULL; const char *serviced_uuid = NULL;
if (switch_core_event_hook_remove_receive_message(session, messagehook) == SWITCH_STATUS_SUCCESS) {
dec_use_count(session, SWITCH_FALSE);
switch_core_event_hook_remove_state_change(session, hanguphook);
}
if (!globals.running) { if (!globals.running) {
return; return;
} }
@ -2488,6 +2486,11 @@ SWITCH_STANDARD_APP(fifo_function)
//const char *track_use_count = switch_channel_get_variable(channel, "fifo_track_use_count"); //const char *track_use_count = switch_channel_get_variable(channel, "fifo_track_use_count");
//int do_track = switch_true(track_use_count); //int do_track = switch_true(track_use_count);
if (switch_core_event_hook_remove_receive_message(session, messagehook) == SWITCH_STATUS_SUCCESS) {
dec_use_count(session, SWITCH_FALSE);
switch_core_event_hook_remove_state_change(session, hanguphook);
}
if (!zstr(strat_str)) { if (!zstr(strat_str)) {
if (!strcasecmp(strat_str, "more_ppl")) { if (!strcasecmp(strat_str, "more_ppl")) {
strat = STRAT_MORE_PPL; strat = STRAT_MORE_PPL;
@ -3056,6 +3059,12 @@ SWITCH_STANDARD_APP(fifo_function)
switch_mutex_unlock(node->mutex); switch_mutex_unlock(node->mutex);
} }
} }
if (outbound_id && switch_channel_up(channel)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s is still alive, tracking call.\n", switch_channel_get_name(channel));
fifo_track_call_function(session, outbound_id);
}
} }
done: done:
@ -3543,9 +3552,26 @@ void node_dump(switch_stream_handle_t *stream)
for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) { for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
switch_hash_this(hi, NULL, NULL, &val); switch_hash_this(hi, NULL, NULL, &val);
if ((node = (fifo_node_t *) val)) { if ((node = (fifo_node_t *) val)) {
stream->write_function(stream, "node: %s outbound_name=%s outbound_per_cycle=%d outbound_priority=%d outbound_strategy=%s\n", stream->write_function(stream, "node: %s\n"
node->name, node->outbound_name, node->outbound_per_cycle, " outbound_name: %s\n"
node->outbound_priority, strat_parse(node->outbound_strategy)); " outbound_per_cycle: %d"
" outbound_priority: %d"
" outbound_strategy: %s\n"
" has_outbound: %d\n"
" outbound_priority: %d\n"
" busy: %d\n"
" ready: %d\n"
" waiting: %d\n"
,
node->name, node->outbound_name, node->outbound_per_cycle,
node->outbound_priority, strat_parse(node->outbound_strategy),
node->has_outbound,
node->outbound_priority,
node->busy,
node->ready,
node_consumer_wait_count(node)
);
} }
} }
@ -3911,9 +3937,6 @@ static switch_status_t load_config(int reload, int del_all)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s is a reserved name, use another name please.\n", MANUAL_QUEUE_NAME); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s is a reserved name, use another name please.\n", MANUAL_QUEUE_NAME);
continue; continue;
} }
outbound_strategy = switch_xml_attr(fifo, "outbound_strategy");
if ((val = switch_xml_attr(fifo, "importance"))) { if ((val = switch_xml_attr(fifo, "importance"))) {
if ((imp = atoi(val)) < 0) { if ((imp = atoi(val)) < 0) {
@ -3921,20 +3944,6 @@ static switch_status_t load_config(int reload, int del_all)
} }
} }
if ((val = switch_xml_attr(fifo, "outbound_per_cycle"))) {
if ((outbound_per_cycle = atoi(val)) < 0) {
outbound_per_cycle = 0;
}
}
if ((val = switch_xml_attr(fifo, "outbound_priority"))) {
outbound_priority = atoi(val);
if (outbound_priority < 1 || outbound_priority > 10) {
outbound_priority = 5;
}
}
switch_mutex_lock(globals.mutex); switch_mutex_lock(globals.mutex);
if (!(node = switch_core_hash_find(globals.fifo_hash, name))) { if (!(node = switch_core_hash_find(globals.fifo_hash, name))) {
node = create_node(name, imp, globals.sql_mutex); node = create_node(name, imp, globals.sql_mutex);
@ -3949,13 +3958,34 @@ static switch_status_t load_config(int reload, int del_all)
switch_assert(node); switch_assert(node);
switch_mutex_lock(node->mutex); switch_mutex_lock(node->mutex);
outbound_strategy = switch_xml_attr(fifo, "outbound_strategy");
if ((val = switch_xml_attr(fifo, "outbound_per_cycle"))) {
if ((outbound_per_cycle = atoi(val)) < 0) {
outbound_per_cycle = 1;
}
node->has_outbound = 1;
}
if ((val = switch_xml_attr(fifo, "outbound_priority"))) {
outbound_priority = atoi(val);
if (outbound_priority < 1 || outbound_priority > 10) {
outbound_priority = 5;
}
node->has_outbound = 1;
}
node->outbound_per_cycle = outbound_per_cycle; node->outbound_per_cycle = outbound_per_cycle;
node->outbound_priority = outbound_priority; node->outbound_priority = outbound_priority;
if (outbound_strategy) { if (outbound_strategy) {
node->outbound_strategy = parse_strat(outbound_strategy); node->outbound_strategy = parse_strat(outbound_strategy);
node->has_outbound = 1;
} }
for (member = switch_xml_child(fifo, "member"); member; member = member->next) { for (member = switch_xml_child(fifo, "member"); member; member = member->next) {