/*# Receive event from protocol machine and hand it over to application */ static void nua_application_event(nua_t *dummy, su_msg_r sumsg, nua_ee_data_t *ee) { nua_t *nua = ee->ee_nua; nua_event_data_t *e = ee->ee_data; nua_handle_t *nh = e->e_nh; enter; ee->ee_nua = NULL; e->e_nh = NULL; if (nh == NULL) { /* Xyzzy */ } else if (nh->nh_valid) { if (!nh->nh_ref_by_user) { /* Application must now call nua_handle_destroy() */ nh->nh_ref_by_user = 1; nua_handle_ref(nh); } } else if (!nh->nh_valid) { /* Handle has been destroyed */ if (nua_log->log_level >= 7) { char const *name = nua_event_name((enum nua_event_e)e->e_event) + 4; SU_DEBUG_7(("nua(%p): event %s dropped\n", (void *)nh, name)); } nua_handle_unref(nh); nua_stack_unref(nua); return; } if (e->e_event == nua_r_shutdown && e->e_status >= 200) nua->nua_shutdown_final = 1; if (nua->nua_callback) { nua_event_frame_t frame[1]; su_msg_save(frame->nf_saved, sumsg); frame->nf_next = nua->nua_current, nua->nua_current = frame; nua->nua_callback((enum nua_event_e)e->e_event, e->e_status, e->e_phrase, nua, nua->nua_magic, nh, nh ? nh->nh_magic : NULL, e->e_msg ? sip_object(e->e_msg) : NULL, e->e_tags); su_msg_destroy(frame->nf_saved); nua->nua_current = frame->nf_next; } nua_handle_unref(nh); nua_stack_unref(nua); }
static RakiaSipSession * new_session (RakiaMediaManager *fac, nua_handle_t *nh, TpHandle handle) { RakiaMediaManagerPrivate *priv = RAKIA_MEDIA_MANAGER_GET_PRIVATE (fac); RakiaSipSession *session; gboolean outgoing = (nh == NULL); gboolean immutable_streams = FALSE; g_object_get (priv->conn, "immutable-streams", &immutable_streams, NULL); if (outgoing) { nh = rakia_base_connection_create_handle ( RAKIA_BASE_CONNECTION (priv->conn), handle); } session = rakia_sip_session_new (nh, RAKIA_BASE_CONNECTION (priv->conn), !outgoing, immutable_streams); if (outgoing) { nua_handle_unref (nh); } return session; }
void s2_free_event(struct event *e) { if (e) { if (e->prev) { if ((*e->prev = e->next)) e->next->prev = e->prev; } nua_destroy_event(e->event); nua_handle_unref(e->nh); free(e); } }
void nua_stack_destroy_handle(nua_t *nua, nua_handle_t *nh, tagi_t const *tags) { if (nh->nh_notifier) nua_stack_terminate(nua, nh, (enum nua_event_e)0, NULL); nua_dialog_shutdown(nh, nh->nh_ds); if (nh->nh_ref_by_user) { nh->nh_ref_by_user = 0; nua_handle_unref(nh); } nh_destroy(nua, nh); }
static void nua_event_deinit(nua_ee_data_t *ee) { nua_t *nua = ee->ee_nua; nua_event_data_t *e = ee->ee_data; nua_handle_t *nh = e->e_nh; if (e->e_msg) msg_destroy(e->e_msg), e->e_msg = NULL; if (nh) nua_handle_unref(nh), e->e_nh = NULL; if (nua) nua_stack_unref(nua), ee->ee_nua = NULL; }
static int nh_call_pending(nua_handle_t *nh, sip_time_t now) { nua_dialog_state_t *ds = nh->nh_ds; nua_dialog_usage_t *du; sip_time_t next = now + NUA_STACK_TIMER_INTERVAL / 1000; for (du = ds->ds_usage; du; du = du->du_next) { if (now == 0) break; if (du->du_refresh && du->du_refresh < next) break; } if (du == NULL) return 0; nua_handle_ref(nh); while (du) { nua_dialog_usage_t *du_next = du->du_next; nua_dialog_usage_refresh(nh, ds, du, now); if (du_next == NULL) break; for (du = nh->nh_ds->ds_usage; du; du = du->du_next) if (du == du_next) break; for (; du; du = du->du_next) { if (now == 0) break; if (du->du_refresh && du->du_refresh < next) break; } } nua_handle_unref(nh); return 1; }
void nh_destroy(nua_t *nua, nua_handle_t *nh) { assert(nh); assert(nh != nua->nua_dhandle); if (nh->nh_notifier) nea_server_destroy(nh->nh_notifier), nh->nh_notifier = NULL; while (nh->nh_ds->ds_cr) nua_client_request_complete(nh->nh_ds->ds_cr); while (nh->nh_ds->ds_sr) nua_server_request_destroy(nh->nh_ds->ds_sr); nua_dialog_deinit(nh, nh->nh_ds); if (nh_is_inserted(nh)) nh_remove(nua, nh); nua_handle_unref(nh); /* Remove stack reference */ }
static void nua_client_request_destroy(nua_client_request_t *cr) { nua_handle_t *nh; if (cr == NULL) return; /* Possible references: */ assert(cr->cr_prev == NULL); /* queue */ assert(cr->cr_orq == NULL); /* transaction callback */ assert(cr->cr_timer == NULL); /* timer callback */ nh = cr->cr_owner; nua_destroy_signal(cr->cr_signal); nua_client_bind(cr, NULL); #if HAVE_MEMLEAK_LOG SU_DEBUG_0(("%p %s for %s\n", cr, __func__, cr->cr_methods->crm_method_name)); #endif if (cr->cr_msg) msg_destroy(cr->cr_msg); cr->cr_msg = NULL, cr->cr_sip = NULL; if (cr->cr_orq) nta_outgoing_destroy(cr->cr_orq), cr->cr_orq = NULL; if (cr->cr_target) su_free(nh->nh_home, cr->cr_target); su_free(nh->nh_home, cr); nua_handle_unref(nh); }