static int ln_timeout(lua_State *L) { struct luanotify *N = luaL_checkudata(L, 1, CQS_NOTIFY); int timeout; if ((timeout = notify_timeout(N->notify)) >= 0) { lua_pushnumber(L, (lua_Number)timeout / 1000); return 1; } else { return 0; } } /* ln_timeout() */
void belle_sip_transaction_notify_timeout(belle_sip_transaction_t *t){ /*report the channel as possibly dead. If an alternate IP can be tryied, the channel will notify us with the RETRY state. * Otherwise it will report the error. * We limit this dead channel reporting to REGISTER transactions, who are unlikely to be unresponded. **/ belle_sip_warning("Transaction [%p] reporting timeout, reporting to channel.",t); if (strcmp(belle_sip_request_get_method(t->request),"REGISTER")==0 && belle_sip_channel_notify_timeout(t->channel)==TRUE){ t->timed_out=TRUE; }else { notify_timeout(t); belle_sip_transaction_terminate(t); } }
static void on_channel_state_changed(belle_sip_channel_listener_t *l, belle_sip_channel_t *chan, belle_sip_channel_state_t state){ belle_sip_transaction_t *t=(belle_sip_transaction_t*)l; belle_sip_io_error_event_t ev; belle_sip_transaction_state_t tr_state=belle_sip_transaction_get_state((belle_sip_transaction_t*)t); belle_sip_message("transaction [%p] channel state changed to [%s]" ,t ,belle_sip_channel_state_to_string(state)); switch(state){ case BELLE_SIP_CHANNEL_READY: if (tr_state==BELLE_SIP_TRANSACTION_INIT && BELLE_SIP_OBJECT_IS_INSTANCE_OF(t,belle_sip_client_transaction_t) ){ belle_sip_client_transaction_t *ct = (belle_sip_client_transaction_t*) t; BELLE_SIP_OBJECT_VPTR(ct,belle_sip_client_transaction_t)->send_request(ct); } break; case BELLE_SIP_CHANNEL_DISCONNECTED: case BELLE_SIP_CHANNEL_ERROR: ev.transport=belle_sip_channel_get_transport_name(chan); ev.source=BELLE_SIP_OBJECT(t); ev.port=chan->peer_port; ev.host=chan->peer_name; if ( tr_state!=BELLE_SIP_TRANSACTION_COMPLETED && tr_state!=BELLE_SIP_TRANSACTION_CONFIRMED && tr_state!=BELLE_SIP_TRANSACTION_ACCEPTED && tr_state!=BELLE_SIP_TRANSACTION_TERMINATED) { BELLE_SIP_PROVIDER_INVOKE_LISTENERS_FOR_TRANSACTION(((belle_sip_transaction_t*)t),process_io_error,&ev); } if (t->timed_out) notify_timeout((belle_sip_transaction_t*)t); belle_sip_transaction_terminate(t); break; default: /*ignored*/ break; } }