diff options
author | Gabriele Svelto <gabriele.svelto@gmail.com> | 2012-04-07 23:38:17 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-04-09 06:24:43 +0200 |
commit | 1590bf3fb591c23d6d96a3335247e85c72b39d43 (patch) | |
tree | aef60d1221ccd55deca59c3ce5ca66fbd558026c /src | |
parent | dcc894ec6fb46f0c4739434f8013914b8a6f8a88 (diff) |
Fix fd/handle conversion in /dev/poll poller code
Signed-off-by: Gabriele Svelto <gabriele.svelto@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/devpoll.cpp | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/src/devpoll.cpp b/src/devpoll.cpp index 276f4d8..e9f172b 100644 --- a/src/devpoll.cpp +++ b/src/devpoll.cpp @@ -84,15 +84,17 @@ xs::handle_t xs::devpoll_t::add_fd (fd_t fd_, // Increase the load metric of the thread. adjust_load (1); - return fd_; + return fdtoptr (fd_); } void xs::devpoll_t::rm_fd (handle_t handle_) { - assert (fd_table [handle_].valid); + fd_t fd = ptrtofd (handle_); - devpoll_ctl (handle_, POLLREMOVE); - fd_table [handle_].valid = false; + assert (fd_table [fd].valid); + + devpoll_ctl (fd, POLLREMOVE); + fd_table [fd].valid = false; // Decrease the load metric of the thread. adjust_load (-1); @@ -100,30 +102,38 @@ void xs::devpoll_t::rm_fd (handle_t handle_) void xs::devpoll_t::set_pollin (handle_t handle_) { - devpoll_ctl (handle_, POLLREMOVE); - fd_table [handle_].events |= POLLIN; - devpoll_ctl (handle_, fd_table [handle_].events); + fd_t fd = ptrtofd (handle_); + + devpoll_ctl (fd, POLLREMOVE); + fd_table [fd].events |= POLLIN; + devpoll_ctl (fd, fd_table [fd].events); } void xs::devpoll_t::reset_pollin (handle_t handle_) { - devpoll_ctl (handle_, POLLREMOVE); - fd_table [handle_].events &= ~((short) POLLIN); - devpoll_ctl (handle_, fd_table [handle_].events); + fd_t fd = ptrtofd (handle_); + + devpoll_ctl (fd, POLLREMOVE); + fd_table [fd].events &= ~((short) POLLIN); + devpoll_ctl (fd, fd_table [fd].events); } void xs::devpoll_t::set_pollout (handle_t handle_) { - devpoll_ctl (handle_, POLLREMOVE); - fd_table [handle_].events |= POLLOUT; - devpoll_ctl (handle_, fd_table [handle_].events); + fd_t fd = ptrtofd (handle_); + + devpoll_ctl (fd, POLLREMOVE); + fd_table [fd].events |= POLLOUT; + devpoll_ctl (fd, fd_table [fd].events); } void xs::devpoll_t::reset_pollout (handle_t handle_) { - devpoll_ctl (handle_, POLLREMOVE); - fd_table [handle_].events &= ~((short) POLLOUT); - devpoll_ctl (handle_, fd_table [handle_].events); + fd_t fd = ptrtofd (handle_); + + devpoll_ctl (fd, POLLREMOVE); + fd_table [fd].events &= ~((short) POLLOUT); + devpoll_ctl (fd, fd_table [fd].events); } void xs::devpoll_t::xstart () |