diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2014-08-06 14:30:39 +0200 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2014-08-07 13:06:22 +0200 |
commit | 5333aed1cd832b7fc5cff59b191da67473f8ab6d (patch) | |
tree | 62ef4c7f2b3128e17336bbb3f46ff6bb2df92275 /samsung-ipc/devices/aries | |
parent | ffda67f121bc99de57031344d75ee1445bc9dd6f (diff) | |
download | hardware_replicant_libsamsung-ipc-5333aed1cd832b7fc5cff59b191da67473f8ab6d.tar.gz hardware_replicant_libsamsung-ipc-5333aed1cd832b7fc5cff59b191da67473f8ab6d.tar.bz2 hardware_replicant_libsamsung-ipc-5333aed1cd832b7fc5cff59b191da67473f8ab6d.zip |
External fds polling support
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'samsung-ipc/devices/aries')
-rw-r--r-- | samsung-ipc/devices/aries/aries.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/samsung-ipc/devices/aries/aries.c b/samsung-ipc/devices/aries/aries.c index c285ba6..321a982 100644 --- a/samsung-ipc/devices/aries/aries.c +++ b/samsung-ipc/devices/aries/aries.c @@ -623,11 +623,14 @@ int aries_write(void *data, const void *buffer, size_t length) return rc; } -int aries_poll(void *data, struct timeval *timeout) +int aries_poll(void *data, struct ipc_poll_fds *fds, struct timeval *timeout) { struct aries_transport_data *transport_data; - fd_set fds; + fd_set set; int fd; + int fd_max; + unsigned int i; + unsigned int count; int rc; if (data == NULL) @@ -639,10 +642,36 @@ int aries_poll(void *data, struct timeval *timeout) if (fd < 0) return -1; - FD_ZERO(&fds); - FD_SET(fd, &fds); + FD_ZERO(&set); + FD_SET(fd, &set); + + fd_max = fd; + + if (fds != NULL && fds->fds != NULL && fds->count > 0) { + for (i = 0; i < fds->count; i++) { + if (fds->fds[i] >= 0) { + FD_SET(fds->fds[i], &set); + + if (fds->fds[i] > fd_max) + fd_max = fds->fds[i]; + } + } + } + + rc = select(fd_max + 1, &set, NULL, NULL, timeout); + + if (fds != NULL && fds->fds != NULL && fds->count > 0) { + count = fds->count; - rc = select(fd + 1, &fds, NULL, NULL, timeout); + for (i = 0; i < fds->count; i++) { + if (!FD_ISSET(fds->fds[i], &set)) { + fds->fds[i] = -1; + count--; + } + } + + fds->count = count; + } return rc; } |