Exemplo n.º 1
0
void nua_stack_deinit(su_root_t *root, nua_t *nua)
{
  enter;

  su_timer_destroy(nua->nua_shutdown_timer), nua->nua_shutdown_timer = NULL;
  nta_agent_destroy(nua->nua_nta), nua->nua_nta = NULL;
}
Exemplo n.º 2
0
/** @internal Shut down stack. */
void nua_stack_shutdown(nua_t *nua)
{
  nua_handle_t *nh, *nh_next;
  int busy = 0;
  sip_time_t now = sip_now();
  int status;
  char const *phrase;

  enter;

  if (!nua->nua_shutdown)
    nua->nua_shutdown = now;

  for (nh = nua->nua_handles; nh; nh = nh_next) {
    nua_dialog_state_t *ds = nh->nh_ds;

    nh_next = nh->nh_next;

    busy += nua_dialog_repeat_shutdown(nh, ds);

    if (nh->nh_soa) {
      soa_destroy(nh->nh_soa), nh->nh_soa = NULL;
    }

    if (nua_client_request_pending(ds->ds_cr))
      busy++;

    if (nh_notifier_shutdown(nh, NULL, NEATAG_REASON("noresource"), TAG_END()))
      busy++;
  }

  if (!busy)
    SET_STATUS(200, "Shutdown successful");
  else if (now == nua->nua_shutdown)
    SET_STATUS(100, "Shutdown started");
  else if (now - nua->nua_shutdown < 30)
    SET_STATUS(101, "Shutdown in progress");
  else
    SET_STATUS(500, "Shutdown timeout");

  if (status >= 200) {
    for (nh = nua->nua_handles; nh; nh = nh_next) {
      nh_next = nh->nh_next;
      while (nh->nh_ds && nh->nh_ds->ds_usage) {
	nua_dialog_usage_remove(nh, nh->nh_ds, nh->nh_ds->ds_usage, NULL, NULL);
      }
    }
    su_timer_destroy(nua->nua_timer), nua->nua_timer = NULL;
    nta_agent_destroy(nua->nua_nta), nua->nua_nta = NULL;
  }

  nua_stack_event(nua, NULL, NULL, nua_r_shutdown, status, phrase, NULL);
}
Exemplo n.º 3
0
static int luasofia_nta_agent_destroy(lua_State* L)
{
    /* get and check first argument (should be a luasofia_nua_handle_t) */
    luasofia_nta_agent_t *agent = (luasofia_nta_agent_t*)luaL_checkudata(L, -1, NTA_AGENT_MTABLE);

    if (agent->agent) {
        /* remove userdata_table[nta_agent_lightudata] = nta_agent_fulludata */
        luasofia_userdata_table_remove(L, agent->agent);
        nta_agent_destroy(agent->agent); 	
        agent->agent = NULL;

        /* unref the lua callback function */
        luaL_unref(L, LUA_REGISTRYINDEX, agent->callback_ref);
    }

    return 0;
}