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.

> 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? 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.

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]

Reply via email to