From 5c815447bfd421c39576a18368e263bcd3e3b383 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 19 Apr 2008 15:57:19 +0000 Subject: [PATCH] deal with untimely pri messages that mess up the state machine git-svn-id: http://svn.openzap.org/svn/openzap/trunk@464 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/openzap/src/include/zap_types.h | 3 ++- libs/openzap/src/zap_isdn.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libs/openzap/src/include/zap_types.h b/libs/openzap/src/include/zap_types.h index b515a1f00d..c0334bffd9 100644 --- a/libs/openzap/src/include/zap_types.h +++ b/libs/openzap/src/include/zap_types.h @@ -184,10 +184,11 @@ typedef enum { ZAP_SIGEVENT_MISC, ZAP_SIGEVENT_COLLECTED_DIGIT, ZAP_SIGEVENT_ADD_CALL, + ZAP_SIGEVENT_RESTART, ZAP_SIGEVENT_INVALID } zap_signal_event_t; #define SIGNAL_STRINGS "START", "STOP", "TRANSFER", "ANSWER", "UP", "FLASH", "PROGRESS", \ - "PROGRESS_MEDIA", "NOTIFY", "TONE_DETECTED", "ALARM_TRAP", "ALARM_CLEAR", "MISC", "COLLECTED_DIGIT", "ADD_CALL", "INVALID" + "PROGRESS_MEDIA", "NOTIFY", "TONE_DETECTED", "ALARM_TRAP", "ALARM_CLEAR", "MISC", "COLLECTED_DIGIT", "ADD_CALL", "RESTART", "INVALID" ZAP_STR2ENUM_P(zap_str2zap_signal_event, zap_signal_event2str, zap_signal_event_t) typedef enum { diff --git a/libs/openzap/src/zap_isdn.c b/libs/openzap/src/zap_isdn.c index a235638542..2b7de4a180 100644 --- a/libs/openzap/src/zap_isdn.c +++ b/libs/openzap/src/zap_isdn.c @@ -150,10 +150,15 @@ static L3INT zap_isdn_931_34(void *pvt, L2UCHAR *msg, L2INT mlen) case Q931mes_RELEASE: case Q931mes_RELEASE_COMPLETE: { + const char *what = gen->MesType == Q931mes_RELEASE ? "Release" : "Release Complete"; if (zchan) { - zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN); + if (zchan->state == ZAP_CHANNEL_STATE_TERMINATING || zchan->state == ZAP_CHANNEL_STATE_HANGUP) { + zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN); + } else { + zap_log(ZAP_LOG_DEBUG, "Ignoring %s on channel %d\n", what, chan_id); + } } else { - zap_log(ZAP_LOG_CRIT, "Received Release Complete with no matching channel %d\n", chan_id); + zap_log(ZAP_LOG_CRIT, "Received %s with no matching channel %d\n", what, chan_id); } } break; @@ -374,6 +379,8 @@ static __inline__ void state_advance(zap_channel_t *zchan) if (zchan->last_state != ZAP_CHANNEL_STATE_HANGUP && zchan->last_state != ZAP_CHANNEL_STATE_DOWN) { zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP); } else { + sig.event_id = ZAP_SIGEVENT_RESTART; + status = isdn_data->sig_cb(&sig); zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN); } }