FS-3594 --resolve

This commit is contained in:
Anthony Minessale 2011-10-03 18:53:17 -05:00
parent d39b7c6b1a
commit efeaf2069e
2 changed files with 12 additions and 2 deletions

View File

@ -625,6 +625,7 @@ struct sofia_profile {
uint32_t event_timeout; uint32_t event_timeout;
int watchdog_enabled; int watchdog_enabled;
switch_mutex_t *gw_mutex; switch_mutex_t *gw_mutex;
uint32_t queued_events;
}; };
struct private_object { struct private_object {

View File

@ -1137,6 +1137,7 @@ void sofia_process_dispatch_event(sofia_dispatch_event_t **dep)
sofia_dispatch_event_t *de = *dep; sofia_dispatch_event_t *de = *dep;
nua_handle_t *nh = de->nh; nua_handle_t *nh = de->nh;
nua_t *nua = de->nua; nua_t *nua = de->nua;
sofia_profile_t *profile = de->profile;
*dep = NULL; *dep = NULL;
@ -1146,6 +1147,10 @@ void sofia_process_dispatch_event(sofia_dispatch_event_t **dep)
nua_destroy_event(de->event); nua_destroy_event(de->event);
su_free(nh->nh_home, de); su_free(nh->nh_home, de);
switch_mutex_lock(profile->flag_mutex);
profile->queued_events--;
switch_mutex_unlock(profile->flag_mutex);
nua_handle_unref(nh); nua_handle_unref(nh);
nua_stack_unref(nua); nua_stack_unref(nua);
} }
@ -1245,6 +1250,10 @@ void sofia_event_callback(nua_event_t event,
{ {
sofia_dispatch_event_t *de; sofia_dispatch_event_t *de;
switch_mutex_lock(profile->flag_mutex);
profile->queued_events++;
switch_mutex_unlock(profile->flag_mutex);
de = su_alloc(nh->nh_home, sizeof(*de)); de = su_alloc(nh->nh_home, sizeof(*de));
memset(de, 0, sizeof(*de)); memset(de, 0, sizeof(*de));
nua_save_event(nua, de->event); nua_save_event(nua, de->event);
@ -1972,7 +1981,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
nua_shutdown(profile->nua); nua_shutdown(profile->nua);
sanity = 10; sanity = 10;
while (!sofia_test_pflag(profile, PFLAG_SHUTDOWN)) { while (!sofia_test_pflag(profile, PFLAG_SHUTDOWN) || profile->queued_events > 0) {
su_root_step(profile->s_root, 1000); su_root_step(profile->s_root, 1000);
if (!--sanity) { if (!--sanity) {
break; break;