Browse Source

Use epoll for wait_write_select

master
Con Kolivas 9 years ago
parent
commit
cab637c9b1
  1. 18
      src/libckpool.c

18
src/libckpool.c

@ -991,19 +991,15 @@ out:
/* Emulate a select write wait for high fds that select doesn't support */ /* Emulate a select write wait for high fds that select doesn't support */
int wait_write_select(int sockd, float timeout) int wait_write_select(int sockd, float timeout)
{ {
struct pollfd sfd; struct epoll_event event;
int ret = -1; int epfd, ret;
if (unlikely(sockd < 0)) epfd = epoll_create1(EPOLL_CLOEXEC);
goto out; event.events = EPOLLOUT | EPOLLRDHUP | EPOLLONESHOT;
sfd.fd = sockd; epoll_ctl(epfd, EPOLL_CTL_ADD, sockd, &event);
sfd.events = POLLOUT | POLLRDHUP;
sfd.revents = 0;
timeout *= 1000; timeout *= 1000;
ret = poll(&sfd, 1, timeout); ret = epoll_wait(epfd, &event, 1, timeout);
if (ret && !(sfd.revents & POLLOUT)) close(epfd);
ret = -1;
out:
return ret; return ret;
} }

Loading…
Cancel
Save