summaryrefslogtreecommitdiff
path: root/boost/asio/detail/impl/epoll_reactor.ipp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/asio/detail/impl/epoll_reactor.ipp')
-rw-r--r--boost/asio/detail/impl/epoll_reactor.ipp28
1 files changed, 26 insertions, 2 deletions
diff --git a/boost/asio/detail/impl/epoll_reactor.ipp b/boost/asio/detail/impl/epoll_reactor.ipp
index 25eb005b32..610ce31ce5 100644
--- a/boost/asio/detail/impl/epoll_reactor.ipp
+++ b/boost/asio/detail/impl/epoll_reactor.ipp
@@ -2,7 +2,7 @@
// detail/impl/epoll_reactor.ipp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -164,7 +164,18 @@ int epoll_reactor::register_descriptor(socket_type descriptor,
ev.data.ptr = descriptor_data;
int result = epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, descriptor, &ev);
if (result != 0)
+ {
+ if (errno == EPERM)
+ {
+ // This file descriptor type is not supported by epoll. However, if it is
+ // a regular file then operations on it will not block. We will allow
+ // this descriptor to be used and fail later if an operation on it would
+ // otherwise require a trip through the reactor.
+ descriptor_data->registered_events_ = 0;
+ return 0;
+ }
return errno;
+ }
return 0;
}
@@ -235,6 +246,13 @@ void epoll_reactor::start_op(int op_type, socket_type descriptor,
return;
}
+ if (descriptor_data->registered_events_ == 0)
+ {
+ op->ec_ = boost::asio::error::operation_not_supported;
+ io_service_.post_immediate_completion(op, is_continuation);
+ return;
+ }
+
if (op_type == write_op)
{
if ((descriptor_data->registered_events_ & EPOLLOUT) == 0)
@@ -256,6 +274,12 @@ void epoll_reactor::start_op(int op_type, socket_type descriptor,
}
}
}
+ else if (descriptor_data->registered_events_ == 0)
+ {
+ op->ec_ = boost::asio::error::operation_not_supported;
+ io_service_.post_immediate_completion(op, is_continuation);
+ return;
+ }
else
{
if (op_type == write_op)
@@ -313,7 +337,7 @@ void epoll_reactor::deregister_descriptor(socket_type descriptor,
// The descriptor will be automatically removed from the epoll set when
// it is closed.
}
- else
+ else if (descriptor_data->registered_events_ != 0)
{
epoll_event ev = { 0, { 0 } };
epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, descriptor, &ev);