mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-05-28 09:38:30 +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,9 +134,9 @@ static int __pri_lpwrap_read(struct pri *pri, void *buf, int buflen)
|
|||||||
spri->errs = 0;
|
spri->errs = 0;
|
||||||
res = (int)len;
|
res = (int)len;
|
||||||
|
|
||||||
|
if (res > 0) {
|
||||||
memset(&((unsigned char*)buf)[res], 0, 2);
|
memset(&((unsigned char*)buf)[res], 0, 2);
|
||||||
res += 2;
|
res += 2;
|
||||||
|
|
||||||
#ifdef IODEBUG
|
#ifdef IODEBUG
|
||||||
{
|
{
|
||||||
char bb[2048] = { 0 };
|
char bb[2048] = { 0 };
|
||||||
@ -145,6 +145,7 @@ static int __pri_lpwrap_read(struct pri *pri, void *buf, int buflen)
|
|||||||
ftdm_log(FTDM_LOG_DEBUG, "READ %d\n", res - 2);
|
ftdm_log(FTDM_LOG_DEBUG, "READ %d\n", res - 2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,11 @@
|
|||||||
#include "private/ftdm_core.h"
|
#include "private/ftdm_core.h"
|
||||||
#include "ftmod_zt.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
|
* \brief Zaptel globals
|
||||||
*/
|
*/
|
||||||
@ -1081,7 +1086,6 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return FTDM_FAIL;
|
return FTDM_FAIL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1100,12 +1104,19 @@ static FIO_READ_FUNCTION(zt_read)
|
|||||||
if ((r = read(ftdmchan->sockfd, data, *datalen)) > 0) {
|
if ((r = read(ftdmchan->sockfd, data, *datalen)) > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else if (r == 0) {
|
||||||
ftdm_sleep(10);
|
ftdm_sleep(10);
|
||||||
if (r == 0) {
|
if (errs) 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) {
|
if (r > 0) {
|
||||||
*datalen = r;
|
*datalen = r;
|
||||||
if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) {
|
if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) {
|
||||||
@ -1113,7 +1124,9 @@ static FIO_READ_FUNCTION(zt_read)
|
|||||||
}
|
}
|
||||||
return FTDM_SUCCESS;
|
return FTDM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
else if (errno == ELAST) {
|
||||||
|
return FTDM_SUCCESS;
|
||||||
|
}
|
||||||
return r == 0 ? FTDM_TIMEOUT : FTDM_FAIL;
|
return r == 0 ? FTDM_TIMEOUT : FTDM_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user