summaryrefslogtreecommitdiff
path: root/boost/asio/detail/impl/kqueue_reactor.ipp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/asio/detail/impl/kqueue_reactor.ipp')
-rw-r--r--boost/asio/detail/impl/kqueue_reactor.ipp28
1 files changed, 25 insertions, 3 deletions
diff --git a/boost/asio/detail/impl/kqueue_reactor.ipp b/boost/asio/detail/impl/kqueue_reactor.ipp
index b4a7a10b71..8057606ce6 100644
--- a/boost/asio/detail/impl/kqueue_reactor.ipp
+++ b/boost/asio/detail/impl/kqueue_reactor.ipp
@@ -312,10 +312,16 @@ void kqueue_reactor::deregister_descriptor(socket_type descriptor,
descriptor_lock.unlock();
- free_descriptor_state(descriptor_data);
- descriptor_data = 0;
-
io_service_.post_deferred_completions(ops);
+
+ // Leave descriptor_data set so that it will be freed by the subsequent
+ // call to cleanup_descriptor_data.
+ }
+ else
+ {
+ // We are shutting down, so prevent cleanup_descriptor_data from freeing
+ // the descriptor_data object and let the destructor free it instead.
+ descriptor_data = 0;
}
}
@@ -345,6 +351,22 @@ void kqueue_reactor::deregister_internal_descriptor(socket_type descriptor,
descriptor_lock.unlock();
+ // Leave descriptor_data set so that it will be freed by the subsequent
+ // call to cleanup_descriptor_data.
+ }
+ else
+ {
+ // We are shutting down, so prevent cleanup_descriptor_data from freeing
+ // the descriptor_data object and let the destructor free it instead.
+ descriptor_data = 0;
+ }
+}
+
+void kqueue_reactor::cleanup_descriptor_data(
+ per_descriptor_data& descriptor_data)
+{
+ if (descriptor_data)
+ {
free_descriptor_state(descriptor_data);
descriptor_data = 0;
}