aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc/devices/crespo/crespo.c
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2014-08-06 14:30:39 +0200
committerPaul Kocialkowski <contact@paulk.fr>2014-08-07 13:06:22 +0200
commit5333aed1cd832b7fc5cff59b191da67473f8ab6d (patch)
tree62ef4c7f2b3128e17336bbb3f46ff6bb2df92275 /samsung-ipc/devices/crespo/crespo.c
parentffda67f121bc99de57031344d75ee1445bc9dd6f (diff)
downloadexternal_libsamsung-ipc-5333aed1cd832b7fc5cff59b191da67473f8ab6d.zip
external_libsamsung-ipc-5333aed1cd832b7fc5cff59b191da67473f8ab6d.tar.gz
external_libsamsung-ipc-5333aed1cd832b7fc5cff59b191da67473f8ab6d.tar.bz2
External fds polling support
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'samsung-ipc/devices/crespo/crespo.c')
-rw-r--r--samsung-ipc/devices/crespo/crespo.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/samsung-ipc/devices/crespo/crespo.c b/samsung-ipc/devices/crespo/crespo.c
index 31bf273..3ddaa03 100644
--- a/samsung-ipc/devices/crespo/crespo.c
+++ b/samsung-ipc/devices/crespo/crespo.c
@@ -388,11 +388,14 @@ int crespo_write(void *data, const void *buffer, size_t length)
return 0;
}
-int crespo_poll(void *data, struct timeval *timeout)
+int crespo_poll(void *data, struct ipc_poll_fds *fds, struct timeval *timeout)
{
struct crespo_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)
@@ -404,10 +407,37 @@ int crespo_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;
+
+ for (i = 0; i < fds->count; i++) {
+ if (!FD_ISSET(fds->fds[i], &set)) {
+ fds->fds[i] = -1;
+ count--;
+ }
+ }
+
+ fds->count = count;
+ }
- rc = select(fd + 1, &fds, NULL, NULL, timeout);
return rc;
}