From cb09c6951e2c4405318b422a1f9213af3e4b6b8a Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Fri, 28 Aug 2009 16:51:46 +0200 Subject: pipe deallocation added --- src/dispatcher.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/dispatcher.hpp') diff --git a/src/dispatcher.hpp b/src/dispatcher.hpp index 08596cb..cb445ef 100644 --- a/src/dispatcher.hpp +++ b/src/dispatcher.hpp @@ -21,6 +21,7 @@ #define __ZMQ_DISPATCHER_HPP_INCLUDED__ #include +#include #include #include @@ -85,6 +86,11 @@ namespace zmq // Taskset specifies which I/O threads are eligible (0 = all). class io_thread_t *choose_io_thread (uint64_t taskset_); + // All pipes are registered with the dispatcher so that even the + // orphaned pipes can be deallocated on the terminal shutdown. + void register_pipe (class pipe_t *pipe_); + void unregister_pipe (class pipe_t *pipe_); + private: // Returns the app thread associated with the current thread. @@ -112,6 +118,18 @@ namespace zmq // Synchronisation of accesses to shared thread data. mutex_t threads_sync; + // As pipes may reside in orphaned state in particular moments + // of the pipe shutdown process, i.e. neither pipe reader nor + // pipe writer hold reference to the pipe, we have to hold references + // to all pipes in dispatcher so that we can deallocate them + // during terminal shutdown even though it conincides with the + // pipe being in the orphaned state. + typedef std::set pipes_t; + pipes_t pipes; + + // Synchronisation of access to the pipes repository. + mutex_t pipes_sync; + dispatcher_t (const dispatcher_t&); void operator = (const dispatcher_t&); }; -- cgit v1.2.3