summaryrefslogtreecommitdiff
path: root/src/select.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-02-16 10:04:30 +0900
committerMartin Sustrik <sustrik@250bpm.com>2012-02-16 10:04:30 +0900
commit35797d6c69032fc9eaa472c501b7fbba8e388026 (patch)
treee2405b4d548078506fd80fcf2171d0988d0da561 /src/select.cpp
parent746cabf4868ff4b9bf46e01a16b43943c8e9454c (diff)
Polling handle is a fixed type now.
Polling handle type was previously dependent on polling mechanism used. Now it is void* in all cases. This patch is a first step in the long way to separate the transports from the core library. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/select.cpp')
-rw-r--r--src/select.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/select.cpp b/src/select.cpp
index 634e358..7f05817 100644
--- a/src/select.cpp
+++ b/src/select.cpp
@@ -59,7 +59,7 @@ xs::select_t::~select_t ()
worker.stop ();
}
-xs::select_t::handle_t xs::select_t::add_fd (fd_t fd_, i_poll_events *events_)
+xs::handle_t xs::select_t::add_fd (fd_t fd_, i_poll_events *events_)
{
// Store the file descriptor.
fd_entry_t entry = {fd_, events_};
@@ -79,33 +79,35 @@ xs::select_t::handle_t xs::select_t::add_fd (fd_t fd_, i_poll_events *events_)
// Increase the load metric of the thread.
adjust_load (1);
- return fd_;
+ return fdtoptr (fd_);
}
void xs::select_t::rm_fd (handle_t handle_)
{
+ int fd = ptrtofd (handle_);
+
// Mark the descriptor as retired.
fd_set_t::iterator it;
for (it = fds.begin (); it != fds.end (); ++it)
- if (it->fd == handle_)
+ if (it->fd == fd)
break;
xs_assert (it != fds.end ());
it->fd = retired_fd;
retired = true;
// Stop polling on the descriptor.
- FD_CLR (handle_, &source_set_in);
- FD_CLR (handle_, &source_set_out);
- FD_CLR (handle_, &source_set_err);
+ FD_CLR (fd, &source_set_in);
+ FD_CLR (fd, &source_set_out);
+ FD_CLR (fd, &source_set_err);
// Discard all events generated on this file descriptor.
- FD_CLR (handle_, &readfds);
- FD_CLR (handle_, &writefds);
- FD_CLR (handle_, &exceptfds);
+ FD_CLR (fd, &readfds);
+ FD_CLR (fd, &writefds);
+ FD_CLR (fd, &exceptfds);
// Adjust the maxfd attribute if we have removed the
// highest-numbered file descriptor.
- if (handle_ == maxfd) {
+ if (fd == maxfd) {
maxfd = retired_fd;
for (fd_set_t::iterator it = fds.begin (); it != fds.end (); ++it)
if (it->fd > maxfd)
@@ -118,22 +120,22 @@ void xs::select_t::rm_fd (handle_t handle_)
void xs::select_t::set_pollin (handle_t handle_)
{
- FD_SET (handle_, &source_set_in);
+ FD_SET (ptrtofd (handle_), &source_set_in);
}
void xs::select_t::reset_pollin (handle_t handle_)
{
- FD_CLR (handle_, &source_set_in);
+ FD_CLR (ptrtofd (handle_), &source_set_in);
}
void xs::select_t::set_pollout (handle_t handle_)
{
- FD_SET (handle_, &source_set_out);
+ FD_SET (ptrtofd (handle_), &source_set_out);
}
void xs::select_t::reset_pollout (handle_t handle_)
{
- FD_CLR (handle_, &source_set_out);
+ FD_CLR (ptrtofd (handle_), &source_set_out);
}
void xs::select_t::start ()