ftmod_isdn: Handle zero length read correctly.
ftmod_misdn currently returns len == 0 if the incoming message, that triggered the read() call, does not contain any data. Users of ftdm_channel_read() need to handle this case, or they may possibly end up in an endless loop. This patch reworks the ftdm_channel_read() handling in ftmod_isdn and prevents it from entering an endless loop. The read error counter is reset on first sucessful read w/ data. Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
This commit is contained in:
parent
134973187a
commit
fc9ea9eab0
|
@ -2055,10 +2055,13 @@ static void *ftdm_isdn_run(ftdm_thread_t *me, void *obj)
|
|||
break;
|
||||
default:
|
||||
{
|
||||
errs = 0;
|
||||
if (flags & FTDM_READ) {
|
||||
len = sizeof(frame);
|
||||
if (ftdm_channel_read(isdn_data->dchan, frame, &len) == FTDM_SUCCESS) {
|
||||
if (ftdm_channel_read(isdn_data->dchan, frame, &len) != FTDM_SUCCESS) {
|
||||
ftdm_log_chan_msg(isdn_data->dchan, FTDM_LOG_ERROR, "Failed to read from D-Channel\n");
|
||||
continue;
|
||||
}
|
||||
if (len > 0) {
|
||||
#ifdef HAVE_PCAP
|
||||
if (isdn_pcap_capture_both(isdn_data)) {
|
||||
isdn_pcap_write(isdn_data, frame, len, ISDN_PCAP_INCOMING);
|
||||
|
@ -2066,6 +2069,9 @@ static void *ftdm_isdn_run(ftdm_thread_t *me, void *obj)
|
|||
#endif
|
||||
Q921QueueHDLCFrame(&isdn_data->q921, frame, (int)len);
|
||||
Q921Rx12(&isdn_data->q921);
|
||||
|
||||
/* Successful read, reset error counter */
|
||||
errs = 0;
|
||||
}
|
||||
} else {
|
||||
ftdm_log(FTDM_LOG_DEBUG, "No Read FLAG!\n");
|
||||
|
|
Loading…
Reference in New Issue