Fix for CALL_STOPPED_ACK sent too early in case where both sides of the link hang-up simultaneously

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@956 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
David Yat Sin 2010-01-12 22:39:20 +00:00
parent cf57d7bb0b
commit b11682a956
1 changed files with 27 additions and 4 deletions

View File

@ -189,7 +189,7 @@ static zap_channel_t *find_zchan(zap_span_t *span, sangomabc_short_event_t *even
break; break;
} else { } else {
zchan = NULL; zchan = NULL;
zap_log(ZAP_LOG_ERROR, "Channel %d:%d ~ %d:%d is already in use.\n", zap_log(ZAP_LOG_DEBUG, "Channel %d:%d ~ %d:%d is already in use.\n",
span->channels[i]->span_id, span->channels[i]->span_id,
span->channels[i]->chan_id, span->channels[i]->chan_id,
span->channels[i]->physical_span_id, span->channels[i]->physical_span_id,
@ -736,6 +736,8 @@ static void handle_call_answer(zap_span_t *span, sangomabc_connection_t *mcon, s
} }
} }
static __inline__ void advance_chan_states(zap_channel_t *zchan);
/** /**
* \brief Handler for call start event * \brief Handler for call start event
* \param span Span where event was fired * \param span Span where event was fired
@ -747,10 +749,19 @@ static void handle_call_start(zap_span_t *span, sangomabc_connection_t *mcon, sa
zap_channel_t *zchan; zap_channel_t *zchan;
if (!(zchan = find_zchan(span, (sangomabc_short_event_t*)event, 0))) { if (!(zchan = find_zchan(span, (sangomabc_short_event_t*)event, 0))) {
goto error; if (!(zchan = find_zchan(span, (sangomabc_short_event_t*)event, 1))) {
zap_log(ZAP_LOG_CRIT, "START CANT FIND CHAN %d:%d AT ALL\n", event->span+1,event->chan+1);
goto error;
}
advance_chan_states(zchan);
if (!(zchan = find_zchan(span, (sangomabc_short_event_t*)event, 0))) {
zap_log(ZAP_LOG_CRIT, "START CANT FIND CHAN %d:%d EVEN AFTER STATE ADVANCE\n", event->span+1,event->chan+1);
goto error;
}
} }
if (zap_channel_open_chan(zchan) != ZAP_SUCCESS) { if (zap_channel_open_chan(zchan) != ZAP_SUCCESS) {
zap_log(ZAP_LOG_CRIT, "START CANT OPEN CHAN %d:%d\n", event->span+1,event->chan+1);
goto error; goto error;
} }
@ -788,8 +799,9 @@ static void handle_call_start(zap_span_t *span, sangomabc_connection_t *mcon, sa
return; return;
error: error:
if (!zchan) {
zap_log(ZAP_LOG_CRIT, "START CANT FIND A CHAN %d:%d\n", event->span+1,event->chan+1); zap_log(ZAP_LOG_CRIT, "START CANT FIND A CHAN %d:%d\n", event->span+1,event->chan+1);
}
sangomabc_exec_command(mcon, sangomabc_exec_command(mcon,
event->span, event->span,
@ -1125,6 +1137,17 @@ static __inline__ void state_advance(zap_channel_t *zchan)
} }
} }
static __inline__ void advance_chan_states(zap_channel_t *zchan)
{
zap_mutex_lock(zchan->mutex);
while (zap_test_flag(zchan, ZAP_CHANNEL_STATE_CHANGE)) {
zap_clear_flag(zchan, ZAP_CHANNEL_STATE_CHANGE);
state_advance(zchan);
zap_channel_complete_state(zchan);
}
zap_mutex_unlock(zchan->mutex);
}
/** /**
* \brief Initialises outgoing requests array * \brief Initialises outgoing requests array
*/ */