Permalink
Browse files

Fixes the Win32 backend

  • Loading branch information...
1 parent 7fc51aa commit 984d28cd6d37ca19e499e4164a0ed2ac7de04331 @alobbs alobbs committed Dec 18, 2011
Showing with 21 additions and 18 deletions.
  1. +21 −18 cherokee/fdpoll-win32.c
View
@@ -78,7 +78,7 @@ _free (cherokee_fdpoll_select_t *fdp)
static ret_t
-_add (cherokee_fdpoll_select_t *fdp, int fd, int rw)
+_add (cherokee_fdpoll_select_t *fdp, int fd, int rw_mode)
{
cherokee_fdpoll_t *nfd = FDPOLL(fdp);
@@ -90,15 +90,13 @@ _add (cherokee_fdpoll_select_t *fdp, int fd, int rw)
}
fdp->select_fds[nfd->npollfds] = fd;
- switch (rw) {
- case FDPOLL_MODE_READ:
- FD_SET (fd, &fdp->master_rfdset);
- break;
- case FDPOLL_MODE_WRITE:
- FD_SET (fd, &fdp->master_wfdset);
- break;
- default:
- break;
+
+ if (rw_mode & poll_mode_read) {
+ FD_SET (fd, &fdp->master_rfdset);
+ }
+
+ if (rw_mode & poll_mode_write) {
+ FD_SET (fd, &fdp->master_wfdset);
}
if (fd > fdp->maxfd) {
@@ -140,26 +138,31 @@ _del (cherokee_fdpoll_select_t *fdp, int fd)
static ret_t
-_set_mode (cherokee_fdpoll_select_t *fdp, int fd, int rw)
+_set_mode (cherokee_fdpoll_select_t *fdp, int fd, int rw_mode)
{
ret_t ret;
ret = _del (fdp, fd);
if (unlikely(ret < ret_ok))
return ret;
- return _add (fdp, fd, rw);
+ return _add (fdp, fd, rw_mode);
}
static int
-_check (cherokee_fdpoll_select_t *fdp, int fd, int rw)
+_check (cherokee_fdpoll_select_t *fdp, int fd, int rw_mode)
{
- switch (rw) {
- case FDPOLL_MODE_READ:
- return FD_ISSET (fd, &fdp->working_rfdset);
- case FDPOLL_MODE_WRITE:
- return FD_ISSET (fd, &fdp->working_wfdset);
+ if ((rw_mode & poll_mode_read) &&
+ (FD_ISSET (fd, &fdp->working_rfdset)))
+ {
+ return 1;
+ }
+
+ if ((rw_mode & poll_mode_write) &&
+ (FD_ISSET (fd, &fdp->working_wfdset)))
+ {
+ return 1;
}
return 0;

0 comments on commit 984d28c

Please sign in to comment.