From 545ba61226d0ae2a581a89d60435ae5621c4ebc9 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Fri, 7 Jan 2011 14:15:24 -0500 Subject: [PATCH] freetdm: only ack indications when the channel is nonblocking --- libs/freetdm/src/ftdm_io.c | 9 ++++++++- libs/freetdm/src/ftdm_state.c | 11 ++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index fb153c8062..cbaff7be54 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -2032,6 +2032,11 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_unhold(const char *file, const char FT_DECLARE(void) ftdm_ack_indication(ftdm_channel_t *fchan, ftdm_channel_indication_t indication, ftdm_status_t status) { ftdm_sigmsg_t msg; + + if (!ftdm_test_flag(fchan, FTDM_CHANNEL_IND_ACK_PENDING)) { + return; + } + ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "Acknowledging indication %s in state %s (rc = %d)\n", ftdm_channel_indication2str(indication), ftdm_channel_state2str(fchan->state), status); ftdm_clear_flag(fchan, FTDM_CHANNEL_IND_ACK_PENDING); @@ -2255,7 +2260,9 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const ch } ftdmchan->indication = indication; - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_IND_ACK_PENDING); + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NONBLOCK)) { + ftdm_set_flag(ftdmchan, FTDM_CHANNEL_IND_ACK_PENDING); + } if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Cannot indicate %s in outgoing channel in state %s\n", diff --git a/libs/freetdm/src/ftdm_state.c b/libs/freetdm/src/ftdm_state.c index f6c2c2320c..61cd003942 100644 --- a/libs/freetdm/src/ftdm_state.c +++ b/libs/freetdm/src/ftdm_state.c @@ -79,13 +79,10 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_complete_state(const char *file, const c ftdm_set_flag(fchan, FTDM_CHANNEL_MEDIA); } - /* if there is a pending ack for an indication - * MAINTENANCE WARNING: we're assuming an indication performed - * via state change will involve a single state change - */ - if (ftdm_test_flag(fchan, FTDM_CHANNEL_IND_ACK_PENDING)) { - ftdm_ack_indication(fchan, fchan->indication, FTDM_SUCCESS); - } + /* MAINTENANCE WARNING + * we're assuming an indication performed + * via state change will involve a single state change */ + ftdm_ack_indication(fchan, fchan->indication, FTDM_SUCCESS); hindex = (fchan->hindex == 0) ? (ftdm_array_len(fchan->history) - 1) : (fchan->hindex - 1);