Archived

This forum has been archived. Please start a new discussion on GitHub.

ICE in COM DLL Server can not exit??

I use ice in a COM dll server.It worked well.
But when It exit,it blocked at the Ice::Communicator "destory" method
infinitely!


this is the call stack:

IceUtil::ThreadControl::join() line 50
IceInternal::ThreadPool::joinWithAllThreads() line 349 + 46 bytes
IceInternal::Instance::destroy() line 936
Ice::CommunicatorI::destroy() line 74 + 21 bytes
CCommunicator::Uninit() line 55 + 47 bytes
CSeurityInfoApp::ExitInstance() line 84
DllMain(HINSTANCE__ * 0x10000000, unsigned long 0, void * 0x00000000) line 139
_DllMainCRTStartup(void * 0x10000000, unsigned long 0, void * 0x00000000) line 273 + 17 bytes
NTDLL! 7c94a352()
NTDLL! 7c969dee()
KERNEL32! 7c82b1bb()

the demo project
in the demo project.
CServer is listen on tcp port 10000
CClient is normal client in normal way access cserver.
SeurityInfo is the COM dll server.the dll wrapper the CClient in COM way. encounter the problem that mentioned earlier!!!
Test_SecurityInfo is the C++ Client call the COM dll server.

CServer <===> CClient work well. you can use it test the server service.
CServer <===> SeurityInfo has problem. When SeurityInfo exit,it blocked.

My C++ Developer tool is MS VC++6.0 + SP6.

Hope for help.
Thanks for your attention.

Comments

  • matthew
    matthew NL, Canada
    I looked into your problem, and your example does indeed hang. The problem is that you are attempted to destroy the communicator in the DLL_PROCESS_DETACH notification on the COM object. Destroying the communicator destroys and joins with the threads that it created. The problem is that joining with threads in the DLL_PROCESS_DETACH notification is illegal.

    DllMain (Windows)

    "Because DLL notifications are serialized, entry-point functions should not attempt to communicate with other threads or processes. Deadlocks may occur as a result."

    You are seeing a deadlock, as the documentation says. Therefore, what you must do instead is arrange to destroy the communicator before this notification occurs.
  • Thanks a lot for your quick response.
    I will thank you again when I resolve the problem.
    Thank you and all the other staff.