From a1bc48d15a5d6e78efe744eb7b27b6421cb7222f Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 16 Aug 2006 10:54:06 +0000 Subject: Convert to using ppoll() and pselect() --- hidd/fakehid.c | 10 +++++++++- hidd/main.c | 11 +++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'hidd') diff --git a/hidd/fakehid.c b/hidd/fakehid.c index 91a62fb3..70eba3b4 100644 --- a/hidd/fakehid.c +++ b/hidd/fakehid.c @@ -25,6 +25,7 @@ #include #endif +#define _GNU_SOURCE #include #include #include @@ -44,6 +45,10 @@ #include +#ifdef NEED_PPOLL +#include "ppoll.h" +#endif + static void event(int fd, uint16_t type, uint16_t code, int32_t value) { struct uinput_event event; @@ -282,6 +287,7 @@ int epox_presenter(const bdaddr_t *src, const bdaddr_t *dst, uint8_t channel) unsigned char buf[16]; struct sigaction sa; struct pollfd p; + sigset_t sigs; char addr[18]; int i, fd, sk, len; @@ -313,12 +319,14 @@ int epox_presenter(const bdaddr_t *src, const bdaddr_t *dst, uint8_t channel) sa.sa_handler = sig_hup; sigaction(SIGHUP, &sa, NULL); + sigfillset(&sigs); + p.fd = sk; p.events = POLLIN | POLLERR | POLLHUP; while (!__io_canceled) { p.revents = 0; - if (poll(&p, 1, 500) < 1) + if (ppoll(&p, 1, NULL, &sigs) < 1) continue; len = read(sk, buf, sizeof(buf)); diff --git a/hidd/main.c b/hidd/main.c index 77f80c3f..cd1dceb9 100644 --- a/hidd/main.c +++ b/hidd/main.c @@ -25,6 +25,7 @@ #include #endif +#define _GNU_SOURCE #include #include #include @@ -47,6 +48,10 @@ #include "hidd.h" +#ifdef NEED_PPOLL +#include "ppoll.h" +#endif + enum { NONE, SHOW, @@ -327,9 +332,12 @@ error: static void run_server(int ctl, int csk, int isk, uint8_t subclass, int nosdp, int nocheck, int bootonly, int encrypt, int timeout) { struct pollfd p[2]; + sigset_t sigs; short events; int err, ncsk, nisk; + sigfillset(&sigs); + p[0].fd = csk; p[0].events = POLLIN | POLLERR | POLLHUP; @@ -340,8 +348,7 @@ static void run_server(int ctl, int csk, int isk, uint8_t subclass, int nosdp, i p[0].revents = 0; p[1].revents = 0; - err = poll(p, 2, 500); - if (err <= 0) + if (ppoll(p, 2, NULL, &sigs) < 1) continue; events = p[0].revents | p[1].revents; -- cgit