continue;
}
- if (ev.data.ptr == &dbus_pipe) {
+ if (ev.ptr == &dbus_pipe) {
if (read(dbus_pipe.rd, &c, 1) == 1) {
if (c == 's')
dbus_flush_queue(notify);
for (i = 0; i < nfds; i++) {
- if (ev[i].data.ptr == &capmt->capmt_pipe) {
+ if (ev[i].ptr == &capmt->capmt_pipe) {
ret = read(capmt->capmt_pipe.rd, buf, 1);
if (ret == 1 && buf[0] == 'c') {
capmt_flush_queue(capmt, 0);
continue;
}
- adapter = ev[i].data.ptr;
+ adapter = ev[i].ptr;
if (adapter == NULL)
continue;
if (nfds <= 0)
continue;
- if (ev.data.ptr == &capmt->capmt_pipe) {
+ if (ev.ptr == &capmt->capmt_pipe) {
ret = read(capmt->capmt_pipe.rd, buf, 1);
if (ret == 1 && buf[0] == 'c') {
capmt_flush_queue(capmt, 0);
pthread_mutex_lock(&cc->cc_mutex);
if (r < 0 && ERRNO_AGAIN(errno))
continue;
- if (ev.data.ptr == &cc->cc_pipe)
+ if (ev.ptr == &cc->cc_pipe)
read(cc->cc_pipe.rd, buf, sizeof(buf));
- else if (ev.data.ptr == &cc->cc_fd) {
+ else if (ev.ptr == &cc->cc_fd) {
len = sbuf_read(&rbuf, cc->cc_fd);
if (len > 0 && cc->cc_read(cc, &rbuf))
break;
if (atomic_get(&http_running) && !ERRNO_AGAIN(errno))
tvherror(LS_HTTPC, "tvhpoll_wait() error");
} else if (n > 0) {
- if (&http_pipe == ev.data.ptr) {
+ if (&http_pipe == ev.ptr) {
if (read(http_pipe.rd, &c, 1) == 1) {
/* end-of-task */
break;
}
pthread_mutex_lock(&http_lock);
TAILQ_FOREACH(hc, &http_clients, hc_link)
- if (hc == ev.data.ptr)
+ if (hc == ev.ptr)
break;
if (hc == NULL) {
pthread_mutex_unlock(&http_lock);
}
if (r != 1)
continue;
- if (ev.data.ptr != hc) {
+ if (ev.ptr != hc) {
fprintf(stderr, "HTTPCTS: Poll returned a wrong value\n");
goto fatal;
}
} else if ( nfds == 0 ) {
continue;
}
- im = ev.data.ptr;
+ im = ev.ptr;
r = 0;
pthread_mutex_lock(&iptv_lock);
evp = ev;
evp->fd = linuxdvb_ca_pipe.rd;
evp->events = TVHPOLL_IN;
- evp->data.ptr = &linuxdvb_ca_pipe;
+ evp->ptr = &linuxdvb_ca_pipe;
evp++;
evcnt = 1;
pthread_mutex_lock(&linuxdvb_ca_mutex);
}
evp->fd = lcat->lcat_ca_fd;
evp->events = TVHPOLL_IN;
- evp->data.ptr = lcat;
+ evp->ptr = lcat;
evp++;
evcnt++;
}
if (monitor)
tm = tm2;
for (evp = ev; evcnt > 0; evp++, evcnt--) {
- if (evp->data.ptr == &linuxdvb_ca_pipe) {
+ if (evp->ptr == &linuxdvb_ca_pipe) {
do {
l = read(linuxdvb_ca_pipe.rd, buf, sizeof(buf));
} while (l < 0 && errno == EINTR);
}
LIST_FOREACH(lcat, &linuxdvb_all_transports, lcat_all_link) {
if (lcat->lcat_ca_fd < 0) continue;
- if (lcat != evp->data.ptr) continue;
+ if (lcat != evp->ptr) continue;
do {
l = read(lcat->lcat_ca_fd, buf, sizeof(buf));
} while (l < 0 && (r = errno) == EINTR);
/* Setup poll */
efd = tvhpoll_create(2);
memset(ev, 0, sizeof(ev));
- ev[0].events = TVHPOLL_IN;
- ev[0].fd = ev[0].data.fd = dvr;
- ev[1].events = TVHPOLL_IN;
- ev[1].fd = ev[1].data.fd = lfe->lfe_dvr_pipe.rd;
+ ev[0].events = TVHPOLL_IN;
+ ev[0].fd = dvr;
+ ev[0].ptr = lfe;
+ ev[1].events = TVHPOLL_IN;
+ ev[1].fd = lfe->lfe_dvr_pipe.rd;
+ ev[1].ptr = &lfe->lfe_dvr_pipe;
tvhpoll_add(efd, ev, 2);
/* Allocate memory */
}
}
if (nfds < 1) continue;
- if (ev[0].data.fd == lfe->lfe_dvr_pipe.rd) {
+ if (ev[0].ptr == &lfe->lfe_dvr_pipe) {
if (read(lfe->lfe_dvr_pipe.rd, &b, 1) > 0) {
if (b == 'c')
linuxdvb_update_pids(lfe, name, &tuned, pids, ARRAY_SIZE(pids));
}
continue;
}
- if (ev[0].data.fd != dvr) break;
+ if (ev[0].ptr != lfe) break;
nodata = 50;
lfe->lfe_nodata = 0;
}
if (nfds <= 0) continue;
- if (ev[0].data.ptr == NULL) {
+ if (ev[0].ptr == NULL) {
c = read(lfe->sf_dvr_pipe.rd, b, 1);
if (c == 1) {
if (b[0] == 'e') {
}
}
- if (rtsp && ev[0].data.ptr == rtsp) {
+ if (rtsp && ev[0].ptr == rtsp) {
r = http_client_run(rtsp);
if (r < 0) {
http_client_close(rtsp);
if (nfds < 0) continue;
if (nfds == 0) break;
- if (ev[0].data.ptr == NULL) {
+ if (ev[0].ptr == NULL) {
c = read(lfe->sf_dvr_pipe.rd, b, 1);
if (c == 1) {
if (b[0] == 'c') {
goto done;
}
- if (ev[0].data.ptr == rtsp) {
+ if (ev[0].ptr == rtsp) {
tc = 0;
r = http_client_run(rtsp);
if (r < 0) {
memset(ev, 0, sizeof(ev));
nfds = 0;
if ((rtsp_flags & SATIP_SETUP_TCP) == 0) {
- ev[nfds].events = TVHPOLL_IN;
- ev[nfds].fd = rtp->fd;
- ev[nfds].data.ptr = rtp;
+ ev[nfds].events = TVHPOLL_IN;
+ ev[nfds].fd = rtp->fd;
+ ev[nfds].ptr = rtp;
nfds++;
- ev[nfds].events = TVHPOLL_IN;
- ev[nfds].fd = rtcp->fd;
- ev[nfds].data.ptr = rtcp;
+ ev[nfds].events = TVHPOLL_IN;
+ ev[nfds].fd = rtcp->fd;
+ ev[nfds].ptr = rtcp;
nfds++;
} else {
rtsp->hc_io_size = 128 * 1024;
rtsp->hc_rtp_data_received = satip_frontend_rtp_data_received;
}
if (i) {
- ev[nfds].events = TVHPOLL_IN;
- ev[nfds].fd = rtsp->hc_fd;
- ev[nfds].data.ptr = rtsp;
+ ev[nfds].events = TVHPOLL_IN;
+ ev[nfds].fd = rtsp->hc_fd;
+ ev[nfds].ptr = rtsp;
nfds++;
}
tvhpoll_add(efd, ev, nfds);
break;
}
- if (nfds > 0 && ev[0].data.ptr == NULL) {
+ if (nfds > 0 && ev[0].ptr == NULL) {
c = read(lfe->sf_dvr_pipe.rd, b, 1);
if (c == 1) {
if (b[0] == 'c') {
if (nfds < 1) continue;
- if (ev[0].data.ptr == rtsp) {
+ if (ev[0].ptr == rtsp) {
r = http_client_run(rtsp);
if (r < 0) {
if (rtsp->hc_code == 404 && session[0]) {
reply = 1;
}
- if (ev[0].data.ptr == rtcp) {
+ if (ev[0].ptr == rtcp) {
c = recv(rtcp->fd, b, sizeof(b), MSG_DONTWAIT);
if (c > 0) {
pthread_mutex_lock(&lfe->sf_dvr_lock);
continue;
}
- if (ev[0].data.ptr != rtp)
+ if (ev[0].ptr != rtp)
continue;
tc = udp_multirecv_read(&um, rtp->fd, RTP_PKTS, &iovec);
/* the poll set includes the sockfd and the pipe for IPC */
efd = tvhpoll_create(2);
memset(ev, 0, sizeof(ev));
- ev[0].events = TVHPOLL_IN;
- ev[0].fd = ev[0].data.fd = sockfd;
- ev[1].events = TVHPOLL_IN;
- ev[1].fd = ev[1].data.fd = hfe->hf_input_thread_pipe.rd;
+ ev[0].events = TVHPOLL_IN;
+ ev[0].fd = sockfd;
+ ev[0].ptr = hfe;
+ ev[1].events = TVHPOLL_IN;
+ ev[1].fd = hfe->hf_input_thread_pipe.rd;
+ ev[1].ptr = &hfe->hf_input_thread_pipe;
r = tvhpoll_add(efd, ev, 2);
if(r < 0)
nfds = tvhpoll_wait(efd, ev, 1, -1);
if (nfds < 1) continue;
- if (ev[0].data.fd != sockfd) break;
+ if (ev[0].ptr != hfe) break;
if((r = sbuf_tsdebug_read(mmi->mmi_mux, &sb, sockfd)) < 0) {
/* whoopsy */
int nfds;
memset(ev, 0, sizeof(ev));
- ev[0].events = TVHPOLL_IN;
- ev[0].fd = spawn_pipe_info.rd;
- ev[0].data.ptr = &spawn_pipe_info;
- ev[1].events = TVHPOLL_IN;
- ev[1].fd = spawn_pipe_error.rd;
- ev[1].data.ptr = &spawn_pipe_error;
+ ev[0].events = TVHPOLL_IN;
+ ev[0].fd = spawn_pipe_info.rd;
+ ev[0].ptr = &spawn_pipe_info;
+ ev[1].events = TVHPOLL_IN;
+ ev[1].fd = spawn_pipe_error.rd;
+ ev[1].ptr = &spawn_pipe_error;
tvhpoll_add(efd, ev, 2);
while (atomic_get(&spawn_pipe_running)) {
if (r == 0) continue;
- if (ev.data.ptr == &tcp_server_pipe) {
+ if (ev.ptr == &tcp_server_pipe) {
r = read(tcp_server_pipe.rd, &c, 1);
if (r > 0) {
next:
continue;
}
- ts = ev.data.ptr;
+ ts = ev.ptr;
if(ev.events & TVHPOLL_HUP) {
close(ts->serverfd);
{
int i, rc;
#if ENABLE_EPOLL
- struct epoll_event ev;
for (i = 0; i < num; i++) {
- memset(&ev, 0, sizeof(ev));
- ev.data.u64 = evs[i].data.u64;
+ struct epoll_event ev = { 0 };
+ ev.data.ptr = evs[i].ptr;
if (evs[i].events & TVHPOLL_IN) ev.events |= EPOLLIN;
if (evs[i].events & TVHPOLL_OUT) ev.events |= EPOLLOUT;
if (evs[i].events & TVHPOLL_PRI) ev.events |= EPOLLPRI;
tvhpoll_alloc(tp, num);
for (i = 0; i < num; i++) {
if (evs[i].events & TVHPOLL_OUT){
- EV_SET(tp->ev+i, evs[i].fd, EVFILT_WRITE, EV_ADD, 0, 0, (intptr_t*)evs[i].data.u64);
+ EV_SET(tp->ev+i, evs[i].fd, EVFILT_WRITE, EV_ADD, 0, 0, evs[i].ptr);
rc = kevent(tp->fd, tp->ev+i, 1, NULL, 0, NULL);
if (rc == -1) {
tvherror(LS_TVHPOLL, "failed to add kqueue WRITE filter [%d|%d]",
kevent(tp->fd, tp->ev+i, 1, NULL, 0, NULL);
}
if (evs[i].events & TVHPOLL_IN){
- EV_SET(tp->ev+i, evs[i].fd, EVFILT_READ, EV_ADD, 0, 0, (intptr_t*)evs[i].data.u64);
+ EV_SET(tp->ev+i, evs[i].fd, EVFILT_READ, EV_ADD, 0, 0, evs[i].ptr);
rc = kevent(tp->fd, tp->ev+i, 1, NULL, 0, NULL);
if (rc == -1) {
tvherror(LS_TVHPOLL, "failed to add kqueue READ filter [%d|%d]", evs[i].fd, rc);
tvhpoll_event_t ev = { 0 };
ev.fd = fd;
ev.events = events;
- ev.data.ptr = ptr;
+ ev.ptr = ptr;
return tvhpoll_add(tp, &ev, 1);
}
#if ENABLE_EPOLL
nfds = epoll_wait(tp->fd, tp->ev, num, ms);
for (i = 0; i < nfds; i++) {
- evs[i].data.u64 = tp->ev[i].data.u64;
- evs[i].events = 0;
- if (tp->ev[i].events & EPOLLIN) evs[i].events |= TVHPOLL_IN;
- if (tp->ev[i].events & EPOLLOUT) evs[i].events |= TVHPOLL_OUT;
- if (tp->ev[i].events & EPOLLERR) evs[i].events |= TVHPOLL_ERR;
- if (tp->ev[i].events & EPOLLPRI) evs[i].events |= TVHPOLL_PRI;
- if (tp->ev[i].events & EPOLLHUP) evs[i].events |= TVHPOLL_HUP;
+ uint32_t events1 = tp->ev[i].events;
+ uint32_t events2 = 0;
+ if (events1 & EPOLLIN) events2 |= TVHPOLL_IN;
+ if (events1 & EPOLLOUT) events2 |= TVHPOLL_OUT;
+ if (events1 & EPOLLERR) events2 |= TVHPOLL_ERR;
+ if (events1 & EPOLLPRI) events2 |= TVHPOLL_PRI;
+ if (events1 & EPOLLHUP) events2 |= TVHPOLL_HUP;
+ evs[i].events = events2;
+ evs[i].fd = -1;
+ evs[i].ptr = tp->ev[i].data.ptr;
}
#elif ENABLE_KQUEUE
struct timespec tm, *to = NULL;
}
nfds = kevent(tp->fd, NULL, 0, tp->ev, num, to);
for (i = 0; i < nfds; i++) {
- evs[i].fd = tp->ev[i].ident;
- evs[i].events = 0;
- evs[i].data.u64 = (intptr_t)tp->ev[i].udata;
- if (tp->ev[i].filter == EVFILT_WRITE) evs[i].events |= TVHPOLL_OUT;
- if (tp->ev[i].filter == EVFILT_READ) evs[i].events |= TVHPOLL_IN;
- if (tp->ev[i].flags & EV_ERROR) evs[i].events |= TVHPOLL_ERR;
- if (tp->ev[i].flags & EV_EOF) evs[i].events |= TVHPOLL_HUP;
+ uint32_t events2 = 0;
+ if (tp->ev[i].filter == EVFILT_WRITE) events2 |= TVHPOLL_OUT;
+ if (tp->ev[i].filter == EVFILT_READ) events2 |= TVHPOLL_IN;
+ if (tp->ev[i].flags & EV_ERROR) events2 |= TVHPOLL_ERR;
+ if (tp->ev[i].flags & EV_EOF) events2 |= TVHPOLL_HUP;
+ evs[i].events = events2;
+ evs[i].fd = -1; /* tp->ev[i].ident */;
+ evs[i].ptr = tp->ev[i].udata;
}
#else
#endif
typedef struct tvhpoll tvhpoll_t;
typedef struct tvhpoll_event
{
- int fd; // input
- int events;
- union {
- void *ptr;
- uint64_t u64;
- uint32_t u32;
- int fd;
- } data;
+ int fd; // input
+ uint32_t events;
+ void *ptr;
} tvhpoll_event_t;
#define TVHPOLL_IN 0x01
goto error;
memset(&ev, 0, sizeof(ev));
- ev[0].fd = multicast->fd;
- ev[0].events = TVHPOLL_IN;
- ev[0].data.ptr = multicast;
- ev[1].fd = unicast->fd;
- ev[1].events = TVHPOLL_IN;
- ev[1].data.ptr = unicast;
+ ev[0].fd = multicast->fd;
+ ev[0].events = TVHPOLL_IN;
+ ev[0].ptr = multicast;
+ ev[1].fd = unicast->fd;
+ ev[1].events = TVHPOLL_IN;
+ ev[1].ptr = unicast;
tvhpoll_add(poll, ev, 2);
delay_ms = 0;
while (r-- > 0) {
if ((ev[r].events & TVHPOLL_IN) != 0) {
- conn = ev[r].data.ptr;
+ conn = ev[r].ptr;
iplen = sizeof(ip);
size = recvfrom(conn->fd, buf, sizeof(buf), 0,
(struct sockaddr *)&ip, &iplen);