Optimized calls to pri_schedule_del().
There is no need to test if a scheduled event is running before calling pri_schedule_del(). git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@1060 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
parent
6d5aeb7cdd
commit
6d9c1cb0d9
44
q921.c
44
q921.c
@ -139,8 +139,7 @@ static void q921_tei_request(void *vpri)
|
||||
#endif
|
||||
pri->ri = random() % 65535;
|
||||
q921_send_tei(pri, Q921_TEI_IDENTITY_REQUEST, pri->ri, Q921_TEI_GROUP, 1);
|
||||
if (pri->t202_timer)
|
||||
pri_schedule_del(pri, pri->t202_timer);
|
||||
pri_schedule_del(pri, pri->t202_timer);
|
||||
pri->t202_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T202], q921_tei_request, pri);
|
||||
}
|
||||
|
||||
@ -174,8 +173,8 @@ static void q921_send_sabme(void *vpri, int now)
|
||||
{
|
||||
struct pri *pri = vpri;
|
||||
q921_h h;
|
||||
|
||||
pri_schedule_del(pri, pri->sabme_timer);
|
||||
pri->sabme_timer = 0;
|
||||
pri->sabme_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], q921_send_sabme_now, pri);
|
||||
if (!now)
|
||||
return;
|
||||
@ -253,8 +252,7 @@ static void reschedule_t200(struct pri *pri)
|
||||
{
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Restarting T200 timer\n");
|
||||
if (pri->t200_timer)
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
|
||||
}
|
||||
|
||||
@ -262,8 +260,7 @@ static void reschedule_t203(struct pri *pri)
|
||||
{
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Restarting T203 timer\n");
|
||||
if (pri->t203_timer)
|
||||
pri_schedule_del(pri, pri->t203_timer);
|
||||
pri_schedule_del(pri, pri->t203_timer);
|
||||
pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri);
|
||||
}
|
||||
|
||||
@ -311,10 +308,8 @@ static pri_event *q921_ack_rx(struct pri *pri, int ack, int send_untransmitted_f
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
pri_message(pri, "-- Since there was nothing left, stopping T200 counter\n");
|
||||
/* Something was ACK'd. Stop T200 counter */
|
||||
if (pri->t200_timer) {
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri->t200_timer = 0;
|
||||
}
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri->t200_timer = 0;
|
||||
}
|
||||
if (pri->t203_timer) {
|
||||
if (pri->debug & PRI_DEBUG_Q921_DUMP)
|
||||
@ -785,10 +780,8 @@ void q921_dump(struct pri *pri, q921_h *h, int len, int showraw, int txrx)
|
||||
pri_event *q921_dchannel_up(struct pri *pri)
|
||||
{
|
||||
/* Stop any SABME retransmissions */
|
||||
if (pri->sabme_timer) {
|
||||
pri_schedule_del(pri, pri->sabme_timer);
|
||||
pri->sabme_timer = 0;
|
||||
}
|
||||
pri_schedule_del(pri, pri->sabme_timer);
|
||||
pri->sabme_timer = 0;
|
||||
|
||||
/* Reset any rejects */
|
||||
pri->sentrej = 0;
|
||||
@ -833,12 +826,9 @@ void q921_reset(struct pri *pri)
|
||||
pri->v_na = 0;
|
||||
pri->window = pri->timers[PRI_TIMER_K];
|
||||
pri->windowlen = 0;
|
||||
if (pri->sabme_timer)
|
||||
pri_schedule_del(pri, pri->sabme_timer);
|
||||
if (pri->t203_timer)
|
||||
pri_schedule_del(pri, pri->t203_timer);
|
||||
if (pri->t200_timer)
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri_schedule_del(pri, pri->sabme_timer);
|
||||
pri_schedule_del(pri, pri->t203_timer);
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri->sabme_timer = 0;
|
||||
pri->sabme_count = 0;
|
||||
pri->t203_timer = 0;
|
||||
@ -909,10 +899,8 @@ static pri_event *q921_receive_MDL(struct pri *pri, q921_u *h, int len)
|
||||
pri_message(pri, "TEI assignment received for invalid Ri %02x (our is %02x)\n", ri, pri->ri);
|
||||
return NULL;
|
||||
}
|
||||
if (pri->t202_timer) {
|
||||
pri_schedule_del(pri, pri->t202_timer);
|
||||
pri->t202_timer = 0;
|
||||
}
|
||||
pri_schedule_del(pri, pri->t202_timer);
|
||||
pri->t202_timer = 0;
|
||||
if (pri->subchannel && (pri->subchannel->tei == tei)) {
|
||||
pri_error(pri, "TEI already assigned (new is %d, current is %d)\n", tei, pri->subchannel->tei);
|
||||
q921_tei_release_and_reacquire(pri);
|
||||
@ -1082,10 +1070,8 @@ static pri_event *__q921_receive_qualified(struct pri *pri, q921_h *h, int len)
|
||||
}
|
||||
}
|
||||
/* Reset t200 timer if it was somehow going */
|
||||
if (pri->t200_timer) {
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri->t200_timer = 0;
|
||||
}
|
||||
pri_schedule_del(pri, pri->t200_timer);
|
||||
pri->t200_timer = 0;
|
||||
/* Reset and restart t203 timer */
|
||||
reschedule_t203(pri);
|
||||
}
|
||||
|
27
q931.c
27
q931.c
@ -3116,8 +3116,7 @@ static void q931_destroy(struct pri *ctrl, int cr, q931_call *c)
|
||||
"NEW_HANGUP DEBUG: Destroying the call, ourstate %s, peerstate %s\n",
|
||||
q931_call_state_str(cur->ourcallstate),
|
||||
q931_call_state_str(cur->peercallstate));
|
||||
if (cur->retranstimer)
|
||||
pri_schedule_del(ctrl, cur->retranstimer);
|
||||
pri_schedule_del(ctrl, cur->retranstimer);
|
||||
pri_call_apdu_queue_cleanup(cur);
|
||||
free(cur);
|
||||
return;
|
||||
@ -3754,8 +3753,7 @@ int q931_connect(struct pri *ctrl, q931_call *c, int channel, int nonisdn)
|
||||
c->peercallstate = Q931_CALL_STATE_ACTIVE;
|
||||
c->alive = 1;
|
||||
/* Connect request timer */
|
||||
if (c->retranstimer)
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
c->retranstimer = 0;
|
||||
if ((c->ourcallstate == Q931_CALL_STATE_CONNECT_REQUEST) && (ctrl->bri || (!ctrl->subchannel)))
|
||||
c->retranstimer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T313], pri_connect_timeout, c);
|
||||
@ -3797,8 +3795,7 @@ int q931_release(struct pri *ctrl, q931_call *c, int cause)
|
||||
c->causecode = CODE_CCITT;
|
||||
c->causeloc = LOC_PRIV_NET_LOCAL_USER;
|
||||
if (c->acked) {
|
||||
if (c->retranstimer)
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
if (!c->t308_timedout) {
|
||||
c->retranstimer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T308], pri_release_timeout, c);
|
||||
} else {
|
||||
@ -3845,8 +3842,7 @@ int q931_disconnect(struct pri *ctrl, q931_call *c, int cause)
|
||||
c->causecode = CODE_CCITT;
|
||||
c->causeloc = LOC_PRIV_NET_LOCAL_USER;
|
||||
c->sendhangupack = 1;
|
||||
if (c->retranstimer)
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
c->retranstimer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T305], pri_disconnect_timeout, c);
|
||||
return send_message(ctrl, c, Q931_DISCONNECT, disconnect_ies);
|
||||
} else
|
||||
@ -4210,8 +4206,7 @@ static int prepare_to_handle_q931_message(struct pri *ctrl, q931_mh *mh, q931_ca
|
||||
c->progressmask = 0;
|
||||
break;
|
||||
case Q931_CONNECT_ACKNOWLEDGE:
|
||||
if (c->retranstimer)
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
c->retranstimer = 0;
|
||||
break;
|
||||
case Q931_RELEASE:
|
||||
@ -4220,14 +4215,12 @@ static int prepare_to_handle_q931_message(struct pri *ctrl, q931_mh *mh, q931_ca
|
||||
c->causecode = -1;
|
||||
c->causeloc = -1;
|
||||
c->aoc_units = -1;
|
||||
if (c->retranstimer)
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
c->retranstimer = 0;
|
||||
c->useruserinfo[0] = '\0';
|
||||
break;
|
||||
case Q931_RELEASE_COMPLETE:
|
||||
if (c->retranstimer)
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
c->retranstimer = 0;
|
||||
c->useruserinfo[0] = '\0';
|
||||
/* Fall through */
|
||||
@ -5102,8 +5095,7 @@ static int pri_internal_clear(void *data)
|
||||
struct pri *ctrl = c->pri;
|
||||
int res;
|
||||
|
||||
if (c->retranstimer)
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
pri_schedule_del(ctrl, c->retranstimer);
|
||||
c->retranstimer = 0;
|
||||
c->useruserinfo[0] = '\0';
|
||||
c->cause = -1;
|
||||
@ -5190,8 +5182,7 @@ void q931_dl_indication(struct pri *ctrl, int event)
|
||||
pri_message(ctrl, DBGHEAD "cancel call %d on channel %d in state %d (%s)\n", DBGINFO,
|
||||
cur->cr, cur->channelno, cur->ourcallstate,
|
||||
q931_call_state_str(cur->ourcallstate));
|
||||
if (cur->retranstimer)
|
||||
pri_schedule_del(ctrl, cur->retranstimer);
|
||||
pri_schedule_del(ctrl, cur->retranstimer);
|
||||
cur->retranstimer = pri_schedule_event(ctrl, 0, pri_dl_down_cancelcall, cur);
|
||||
}
|
||||
cur = cur->next;
|
||||
|
Loading…
Reference in New Issue
Block a user