From 7e8e99e52ca7c09390a621c41a901fbebd6e8bca Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 6 Dec 2012 11:11:02 -0600 Subject: [PATCH] fix answer contention issue --- src/mod/endpoints/mod_sofia/mod_sofia.c | 9 +-------- src/mod/endpoints/mod_sofia/mod_sofia.h | 1 - src/switch_core_sqldb.c | 14 +++++++++++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 73c50565fe..c75fdce179 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1567,15 +1567,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi de->session = session; } - if (de->data->e_event == nua_i_cancel || de->data->e_event == nua_i_bye) { - sofia_set_flag(tech_pvt, TFLAG_SIGDEAD); - } + sofia_process_dispatch_event(&de); - if (!sofia_test_flag(tech_pvt, TFLAG_SIGDEAD) && (switch_channel_media_up(channel) || switch_channel_get_state(channel) > CS_ROUTING)) { - sofia_queue_message(de); - } else { - sofia_process_dispatch_event(&de); - } switch_mutex_unlock(tech_pvt->sofia_mutex); goto end; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 146ef4fd44..82c68516fb 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -353,7 +353,6 @@ typedef enum { TFLAG_PASS_ACK, TFLAG_CRYPTO_RECOVER, TFLAG_DROP_DTMF, - TFLAG_SIGDEAD, /* No new flags below this line */ TFLAG_MAX } TFLAGS; diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 3860af15d4..802ce6b28a 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -1261,6 +1261,7 @@ struct switch_sql_queue_manager { char *inner_post_trans_execute; switch_memory_pool_t *pool; uint32_t max_trans; + uint32_t confirm; }; static int qm_wake(switch_sql_queue_manager_t *qm) @@ -1431,6 +1432,7 @@ SWITCH_DECLARE(switch_status_t) switch_sql_queue_manager_push_confirm(switch_sql } switch_mutex_lock(qm->mutex); + qm->confirm++; switch_queue_push(qm->sql_queue[pos], dup ? strdup(sql) : (char *)sql); written = qm->pre_written[pos]; size = switch_sql_queue_manager_size(qm, pos); @@ -1451,6 +1453,10 @@ SWITCH_DECLARE(switch_status_t) switch_sql_queue_manager_push_confirm(switch_sql } } + switch_mutex_lock(qm->mutex); + qm->confirm--; + switch_mutex_unlock(qm->mutex); + return SWITCH_STATUS_SUCCESS; } @@ -1733,11 +1739,13 @@ static void *SWITCH_THREAD_FUNC switch_user_sql_thread(switch_thread_t *thread, switch_thread_cond_wait(qm->cond, qm->cond_mutex); } - i = 4; + i = 40; - while (--i > 0 && (lc = qm_ttl(qm)) < qm->max_trans / 4) { - switch_yield(50000); + while (--i > 0 && (lc = qm_ttl(qm)) < qm->max_trans / 4 && !qm->confirm) { + switch_yield(5000); } + + } switch_mutex_unlock(qm->cond_mutex);