diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c index 1549833571..10e0c4ac9f 100644 --- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c +++ b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c @@ -1720,7 +1720,7 @@ static void *ftdm_r2_run(ftdm_thread_t *me, void *obj) /* deliver the actual channel events to the user now without any channel locking */ ftdm_span_trigger_signals(span); -#ifndef WIN32 + /* figure out what event to poll each channel for. POLLPRI when the channel is down, * POLLPRI|POLLIN|POLLOUT otherwise */ memset(poll_events, 0, sizeof(short)*span->chan_count); @@ -1732,16 +1732,12 @@ static void *ftdm_r2_run(ftdm_thread_t *me, void *obj) for (i = 0; citer; citer = ftdm_iterator_next(citer), i++) { ftdmchan = ftdm_iterator_current(citer); r2chan = R2CALL(ftdmchan)->r2chan; - poll_events[i] = POLLPRI; + poll_events[i] = FTDM_EVENTS; if (openr2_chan_get_read_enabled(r2chan)) { - poll_events[i] |= POLLIN; + poll_events[i] |= FTDM_READ; } } - status = ftdm_span_poll_event(span, waitms, poll_events); -#else - status = ftdm_span_poll_event(span, waitms, NULL); -#endif /* run any span timers */ ftdm_sched_run(r2data->sched); diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c index e1b6658945..627ef7bb67 100644 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c +++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c @@ -1051,16 +1051,34 @@ FIO_SPAN_POLL_EVENT_FUNCTION(wanpipe_poll_event) for(i = 1; i <= span->chan_count; i++) { ftdm_channel_t *ftdmchan = span->channels[i]; + uint32_t chan_events = 0; + + /* if the user specify which events to poll the channel for, we translate them from ftdm_wait_flag_t + * to events that either sangoma_waitfor_many() or poll() understands. if not, we poll for POLLPRI */ + if (poll_events) { + if (poll_events[j] & FTDM_READ) { + chan_events = POLLIN; + } + if (poll_events[j] & FTDM_WRITE) { + chan_events |= POLLOUT; + } + if (poll_events[j] & FTDM_EVENTS) { + chan_events |= POLLPRI; + } + } else { + chan_events = POLLPRI; + } + #ifdef LIBSANGOMA_VERSION if (!ftdmchan->io_data) { continue; /* should never happen but happens when shutting down */ } pfds[j] = ftdmchan->io_data; - inflags[j] = poll_events ? poll_events[j] : POLLPRI; + inflags[j] = chan_events; #else memset(&pfds[j], 0, sizeof(pfds[j])); pfds[j].fd = span->channels[i]->sockfd; - pfds[j].events = poll_events ? poll_events[j] : POLLPRI; + pfds[j].events = chan_events; #endif /* The driver probably should be able to do this wink/flash/ringing by itself this is sort of a hack to make it work! */