mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-13 15:50:59 +00:00
freetdm: ftmod_libpri + ftmod_zt: some DAHDI drivers return an error of ELAST (500) on read()/write() to indicate there are events pending.
Fixup zt_read() to handle this case correctly and rework ftmod_libpri's read wrapper function to not fail when the read function returns zero bytes. NOTE: zt_write() has not been changed (some better way to handle these events is needed then) This should fix these log messages: [WARNING] ftdm_io.c:3561 [s1c16][1:16] raw I/O read filed [CRIT] lpwrap_pri.c:125 span 1 D-READ FAIL! [] [CRIT] lpwrap_pri.c:157 span 1 D-WRITE FAIL! [] [ERR] ftmod_libpri.c:131 Short write: -1/6 (Unknown error 500) Signed-off-by: Stefan Knoblich <s.knoblich@axsentis.de>
This commit is contained in:
parent
6a36b8f33f
commit
60cb91b042
@ -134,17 +134,18 @@ static int __pri_lpwrap_read(struct pri *pri, void *buf, int buflen)
|
||||
spri->errs = 0;
|
||||
res = (int)len;
|
||||
|
||||
memset(&((unsigned char*)buf)[res], 0, 2);
|
||||
res += 2;
|
||||
|
||||
if (res > 0) {
|
||||
memset(&((unsigned char*)buf)[res], 0, 2);
|
||||
res += 2;
|
||||
#ifdef IODEBUG
|
||||
{
|
||||
char bb[2048] = { 0 };
|
||||
{
|
||||
char bb[2048] = { 0 };
|
||||
|
||||
print_hex_bytes(buf, res - 2, bb, sizeof(bb));
|
||||
ftdm_log(FTDM_LOG_DEBUG, "READ %d\n", res - 2);
|
||||
}
|
||||
print_hex_bytes(buf, res - 2, bb, sizeof(bb));
|
||||
ftdm_log(FTDM_LOG_DEBUG, "READ %d\n", res - 2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,11 @@
|
||||
#include "private/ftdm_core.h"
|
||||
#include "ftmod_zt.h"
|
||||
|
||||
/* used by dahdi to indicate there is no data available, but events to read */
|
||||
#ifndef ELAST
|
||||
#define ELAST 500
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Zaptel globals
|
||||
*/
|
||||
@ -1081,7 +1086,6 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event)
|
||||
}
|
||||
|
||||
return FTDM_FAIL;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1100,12 +1104,19 @@ static FIO_READ_FUNCTION(zt_read)
|
||||
if ((r = read(ftdmchan->sockfd, data, *datalen)) > 0) {
|
||||
break;
|
||||
}
|
||||
ftdm_sleep(10);
|
||||
if (r == 0) {
|
||||
errs--;
|
||||
else if (r == 0) {
|
||||
ftdm_sleep(10);
|
||||
if (errs) errs--;
|
||||
}
|
||||
else {
|
||||
if (errno == EAGAIN || errno == EINTR)
|
||||
continue;
|
||||
if (errno == ELAST)
|
||||
break;
|
||||
|
||||
ftdm_log(FTDM_LOG_ERROR, "read failed: %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
if (r > 0) {
|
||||
*datalen = r;
|
||||
if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) {
|
||||
@ -1113,7 +1124,9 @@ static FIO_READ_FUNCTION(zt_read)
|
||||
}
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
else if (errno == ELAST) {
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
return r == 0 ? FTDM_TIMEOUT : FTDM_FAIL;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user