On 05/27/2010 04:18 PM, Steve Huston wrote:
Hi Gordon,
I've been trying to debug this issue a little, and am looking
for some information (from Steve and Andrew in particular).
One issue appears to be that the IO threads are terminated by the c++
runtime *before* the IOThread destructor is called. This
termination is
abrupt and they do not get a chance to finish processing any
outstanding
completions (meaning they never call the close callback on
the dispatch
handle which prevents the Connector+ConnectionImpl code from cleaning
itself up correctly).
Right.
I would have expected that all destructors for global and
static objects
would be called before terminating threads. Does anyone have
any insight into the way this works on windows?
Returning from main() effectively calls ExitProcess() which blows
threads away first, without cleanup. DLLs are unloaded later, and that's
when the global/static objects are destroyed.
Thanks for the authoritative answer! That matches what I'm seeing and I
think confirms the design is broker for windows.
Is the fact that the
IOThread static is in a dynamic library relevant here?
Yes, I believe it is.
Is there a reason this needs to be a static?
This goes back to the threading changes Andrew introduced in
http://svn.apache.org/viewvc?view=revision&revision=901550. A single
Poller and thread pool are now shared between connections in the form of
a static IOThreads instance created on demand.
Another idea that would
resolve the cleanup thing is to attach IOThread setup/cleanup to the
lifetime of the Connection objects. This would, in most cases, cause
them to be cleaned up on the way out of main, before process cleanup
starts.
There may be something we can do there, I'll have a think about what
would be required.
Alan's idea of explicit init/fini is the best idea in the long run, IMO.
As Qpid's popularity grows it may be ported to more platforms, and this
issue will keep coming back.
-Steve
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]