Browse Source

Replace use of select with poll in *wait_select in libckpool to allow high fds

master
ckolivas 10 years ago
parent
commit
b95ce4070e
  1. 33
      src/libckpool.c

33
src/libckpool.c

@ -29,6 +29,7 @@
#include <sys/time.h>
#include <time.h>
#include <math.h>
#include <poll.h>
#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)

Loading…
Cancel
Save