summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-12-23 13:16:26 (GMT)
committerRemko Tronçon <git@el-tramo.be>2012-12-23 14:43:26 (GMT)
commit491ddd570a752cf9bda85933bed0c6942e39b1f9 (patch)
tree10c25c1be8cc08d0497df1dccd56a10fbb30beee /3rdParty/Boost/src/boost/asio/detail/impl/eventfd_select_interrupter.ipp
parentda7d7a0ca71b80281aa9ff2526290b61ccb0cc60 (diff)
downloadswift-491ddd570a752cf9bda85933bed0c6942e39b1f9.zip
swift-491ddd570a752cf9bda85933bed0c6942e39b1f9.tar.bz2
Update Boost to 1.52.0.
Change-Id: I1e56bea2600bf2ed9c5b3aba8c4f9d2a0f350e77
Diffstat (limited to '3rdParty/Boost/src/boost/asio/detail/impl/eventfd_select_interrupter.ipp')
-rw-r--r--3rdParty/Boost/src/boost/asio/detail/impl/eventfd_select_interrupter.ipp49
1 files changed, 44 insertions, 5 deletions
diff --git a/3rdParty/Boost/src/boost/asio/detail/impl/eventfd_select_interrupter.ipp b/3rdParty/Boost/src/boost/asio/detail/impl/eventfd_select_interrupter.ipp
index d270b31..22154bb 100644
--- a/3rdParty/Boost/src/boost/asio/detail/impl/eventfd_select_interrupter.ipp
+++ b/3rdParty/Boost/src/boost/asio/detail/impl/eventfd_select_interrupter.ipp
@@ -2,7 +2,7 @@
// detail/impl/eventfd_select_interrupter.ipp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2008 Roelof Naude (roelof.naude at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -40,24 +40,48 @@ namespace detail {
eventfd_select_interrupter::eventfd_select_interrupter()
{
+ open_descriptors();
+}
+
+void eventfd_select_interrupter::open_descriptors()
+{
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 8
write_descriptor_ = read_descriptor_ = syscall(__NR_eventfd, 0);
-#else // __GLIBC__ == 2 && __GLIBC_MINOR__ < 8
- write_descriptor_ = read_descriptor_ = ::eventfd(0, 0);
-#endif // __GLIBC__ == 2 && __GLIBC_MINOR__ < 8
if (read_descriptor_ != -1)
{
::fcntl(read_descriptor_, F_SETFL, O_NONBLOCK);
+ ::fcntl(read_descriptor_, F_SETFD, FD_CLOEXEC);
}
- else
+#else // __GLIBC__ == 2 && __GLIBC_MINOR__ < 8
+# if defined(EFD_CLOEXEC) && defined(EFD_NONBLOCK)
+ write_descriptor_ = read_descriptor_ =
+ ::eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
+# else // defined(EFD_CLOEXEC) && defined(EFD_NONBLOCK)
+ errno = EINVAL;
+ write_descriptor_ = read_descriptor_ = -1;
+# endif // defined(EFD_CLOEXEC) && defined(EFD_NONBLOCK)
+ if (read_descriptor_ == -1 && errno == EINVAL)
+ {
+ write_descriptor_ = read_descriptor_ = ::eventfd(0, 0);
+ if (read_descriptor_ != -1)
+ {
+ ::fcntl(read_descriptor_, F_SETFL, O_NONBLOCK);
+ ::fcntl(read_descriptor_, F_SETFD, FD_CLOEXEC);
+ }
+ }
+#endif // __GLIBC__ == 2 && __GLIBC_MINOR__ < 8
+
+ if (read_descriptor_ == -1)
{
int pipe_fds[2];
if (pipe(pipe_fds) == 0)
{
read_descriptor_ = pipe_fds[0];
::fcntl(read_descriptor_, F_SETFL, O_NONBLOCK);
+ ::fcntl(read_descriptor_, F_SETFD, FD_CLOEXEC);
write_descriptor_ = pipe_fds[1];
::fcntl(write_descriptor_, F_SETFL, O_NONBLOCK);
+ ::fcntl(write_descriptor_, F_SETFD, FD_CLOEXEC);
}
else
{
@@ -70,12 +94,27 @@ eventfd_select_interrupter::eventfd_select_interrupter()
eventfd_select_interrupter::~eventfd_select_interrupter()
{
+ close_descriptors();
+}
+
+void eventfd_select_interrupter::close_descriptors()
+{
if (write_descriptor_ != -1 && write_descriptor_ != read_descriptor_)
::close(write_descriptor_);
if (read_descriptor_ != -1)
::close(read_descriptor_);
}
+void eventfd_select_interrupter::recreate()
+{
+ close_descriptors();
+
+ write_descriptor_ = -1;
+ read_descriptor_ = -1;
+
+ open_descriptors();
+}
+
void eventfd_select_interrupter::interrupt()
{
uint64_t counter(1UL);