From b95ce4070e1590fbc1a27b4357a5fcb703871479 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Mon, 27 Oct 2014 23:55:39 +1100 Subject: [PATCH] Replace use of select with poll in *wait_select in libckpool to allow high fds --- src/libckpool.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/libckpool.c b/src/libckpool.c index ad6be2ea..43be56ec 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "libckpool.h" #include "sha2.h" @@ -704,17 +705,17 @@ out: return sockd; } +/* Emulate a select read wait for high fds that select doesn't support */ int wait_read_select(int sockd, int timeout) { - tv_t tv_timeout; - fd_set readfs; - - tv_timeout.tv_sec = timeout; - tv_timeout.tv_usec = 0; + struct pollfd sfd; + int ret; - FD_ZERO(&readfs); - FD_SET(sockd, &readfs); - return select(sockd + 1, &readfs, NULL, NULL, &tv_timeout); + sfd.fd = sockd; + sfd.events = POLLIN; + sfd.revents = 0; + timeout *= 1000; + return poll(&sfd, 1, timeout); } int read_length(int sockd, void *buf, int len) @@ -778,17 +779,17 @@ out: return buf; } +/* Emulate a select write wait for high fds that select doesn't support */ int wait_write_select(int sockd, int timeout) { - tv_t tv_timeout; - fd_set writefds; - - tv_timeout.tv_sec = timeout; - tv_timeout.tv_usec = 0; + struct pollfd sfd; + int ret; - FD_ZERO(&writefds); - FD_SET(sockd, &writefds); - return select(sockd + 1, NULL, &writefds, NULL, &tv_timeout); + sfd.fd = sockd; + sfd.events = POLLOUT; + sfd.revents = 0; + timeout *= 1000; + return poll(&sfd, 1, timeout); } int write_length(int sockd, const void *buf, int len)