From f2841e028044241c8a9c1e1cba047175329f42d0 Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Fri, 23 Mar 2012 01:00:26 +0100 Subject: [PATCH] ftmod_misdn: misdn_write() workaround for signalling drivers that do not use write polling. Wait till the channel is actually ready to send data. Signed-off-by: Stefan Knoblich --- libs/freetdm/src/ftmod/ftmod_misdn/ftmod_misdn.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libs/freetdm/src/ftmod/ftmod_misdn/ftmod_misdn.c b/libs/freetdm/src/ftmod/ftmod_misdn/ftmod_misdn.c index 3080de52f2..410722fd53 100644 --- a/libs/freetdm/src/ftmod/ftmod_misdn/ftmod_misdn.c +++ b/libs/freetdm/src/ftmod/ftmod_misdn/ftmod_misdn.c @@ -1261,6 +1261,7 @@ static FIO_WRITE_FUNCTION(misdn_write) struct mISDNhead *hh = (struct mISDNhead *)wbuf; int size = *datalen; int retval = 0; + ftdm_wait_flag_t wflags; assert(priv); @@ -1284,6 +1285,15 @@ static FIO_WRITE_FUNCTION(misdn_write) memcpy(wbuf + MISDN_HEADER_LEN, data, size); size += MISDN_HEADER_LEN; + /* wait for channel to get ready */ + wflags = FTDM_WRITE; + retval = misdn_wait(ftdmchan, &wflags, 20); + if (retval) { + /* timeout, io error */ + *datalen = 0; + return FTDM_FAIL; + } + #ifdef MISDN_DEBUG_IO ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "mISDN writing %d bytes to channel socket %d [dev.ch: %d.%d]\n", size, ftdmchan->sockfd, priv->addr.dev, priv->addr.channel);