sofia_dispatch_event_t *de = *dep;
nua_handle_t *nh = de->nh;
nua_t *nua = de->nua;
-
+ sofia_profile_t *profile = de->profile;
+
*dep = NULL;
our_sofia_event_callback(de->data->e_event, de->data->e_status, de->data->e_phrase, de->nua, de->profile,
nua_destroy_event(de->event);
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_stack_unref(nua);
{
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));
memset(de, 0, sizeof(*de));
nua_save_event(nua, de->event);
nua_shutdown(profile->nua);
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);
if (!--sanity) {
break;