#include <errno.h>
#include "iobuf.h"
#include "iopoll.h"

int iobuf_timeout(iobuf* io, int poll_out)
{
  iopoll_fd pfd;
  int result;
  
  if (!io->timeout) return 1;

  pfd.fd = io->fd;
  pfd.events = poll_out ? IOPOLL_WRITE : IOPOLL_READ;
  while ((result = iopoll(&pfd, 1, io->timeout)) == -1) {
    if (errno == EAGAIN) continue;
    IOBUF_SET_ERROR(io);
  }
  if (result) return 1;
  io->flags |= IOBUF_TIMEOUT;
  return 0;
}

#include <errno.h>
#include <sys/poll.h>
#include "iobuf.h"

int iobuf_timeout(iobuf* io, int poll_out)
{
  struct pollfd pfd;
  int result;
  
  if (!io->timeout) return 1;

  pfd.fd = io->fd;
  pfd.events = poll_out ? POLLOUT : POLLIN;
  while ((result = poll(&pfd, 1, io->timeout)) == -1) {
    if (errno == EAGAIN) continue;
    IOBUF_SET_ERROR(io);
  }
  if (result) return 1;
  io->flags |= IOBUF_TIMEOUT;
  return 0;
}

--- 
+++ 
@@ -1,17 +1,17 @@
 #include <errno.h>
-#include <sys/poll.h>
 #include "iobuf.h"
+#include "iopoll.h"
 
 int iobuf_timeout(iobuf* io, int poll_out)
 {
-  struct pollfd pfd;
+  iopoll_fd pfd;
   int result;
   
   if (!io->timeout) return 1;
 
   pfd.fd = io->fd;
-  pfd.events = poll_out ? POLLOUT : POLLIN;
-  while ((result = poll(&pfd, 1, io->timeout)) == -1) {
+  pfd.events = poll_out ? IOPOLL_WRITE : IOPOLL_READ;
+  while ((result = iopoll(&pfd, 1, io->timeout)) == -1) {
     if (errno == EAGAIN) continue;
     IOBUF_SET_ERROR(io);
   }
Use iopoll instead of poll directly.

