ATL Service Deadlock 
Author Message
 ATL Service Deadlock

Hi,

I have a simple AppWizard( VC 7.0 on XP SP1 ) generated
server which exposes a single coclass.

When apartment threaded it works fine as a server/service.

But when free threaded, it works OK as a local server but
not as a service - it appears to deadlock on a client
cocreateinstance ( which eventually times out ).

Any thoughts?

Regards
Neil Riley



Sun, 29 May 2005 18:44:44 GMT  
 ATL Service Deadlock
I think this is a know bug that was introduces in ATL7.

Have a look at below..... Regards, Brian Muth

Here is info from a KB article that is being written.

When the _ATL_FREE_THREADED macro is defined,
CAtlExeModuleT::PreMessageFilter function registers the server's COM objects
with the REGCLS_SUSPENDED flag, but does not call CoResumeClassObjects.

To work around this problem, override the
CAtlServiceModuleT::PreMessageFilter function as follows

For non-attributed code:

class CAtlServiceModule : public CAtlServiceModuleT<CAtlServiceModule,

IDS_SERVICENAME>

{

public :

...

HRESULT PreMessageLoop(int nShowCmd)

{

HRESULT hr;

hr =
CAtlServiceModuleT<CAtlServiceModule,IDS_SERVICENAME>::PreMessageLoop(nS

howCmd);

#if _ATL_VER == 0x0700

// workaround

if (hr==S_OK && !m_bDelayShutdown)

hr = CoResumeClassObjects();

#else

#error Investigate if workaround is required

#endif

return hr;

Quote:
}
};

For attributed code:

[ module(SERVICE, ...) ]

class CServiceModule

{

public:

HRESULT PreMessageLoop(int nShowCmd)

{

HRESULT hr;

hr =
CAtlServiceModuleT<CServiceModule,IDS_SERVICENAME>::PreMessageLoop(nShow

Cmd);

#if _ATL_VER == 0x0700

// workaround

if (hr==S_OK && !m_bDelayShutdown)

hr = CoResumeClassObjects();

#else

#error Investigate if workaround is required

#endif

return hr;

Quote:
}
};

--

Sridhar Madhugiri

Visual C++ Libraries Team

This posting is provided "AS IS" with no warranties, and confers no rights.

Quote:
-----Original Message-----


Sent: Monday, October 21, 2002 4:17 AM


Subject: [ATL] MTA Service in ATL7 bug

Hi all.

We have created a vanilla COM Service using VC7. By default our COM object
is "declared" CComSingleThreadModel. If we change it to
CComMultiThreadModel, and then #define _ATL_FREE_THREADED instead of
_ATL_APARTMENT_THREADED, then our service will not create objects, in fact,
CoCreateInstance from another process *hangs* until it times out.

_ATL_FREE_THREADED CComMultiThreadModel HANGS

_ATL_APARTMENT_THREADED CComMultiThreadModel Fine

_ATL_APARTMENT_THREADED CComSingleThreadModel Fine

I have heard there is a possible bug in this version of the ATL which may
explain this, can someone point me to a workaround, an article or any
information to help?

Thanks in advance,

Karl



Mon, 30 May 2005 00:35:05 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Help creating a simple service using ATL Service

2. Cannot start service ATL COM Service

3. ATL Service service could not be deleted message???

4. ATL Service only start as service

5. ATL as Service : Service State Handler

6. ATL Service - Sporadically does not report SERVICE STOP in event log

7. ATL Control & ATL Web Service

8. ATL Service calling ATL Out Of Process Server

9. Problem with ATL Service with ATL 7.0

10. Debugging ATL Server Web Services from unmanaged C++ client

11. How to convert ATL project exe to service?

12. VARIANT and ATL Web Service

 

 
Powered by phpBB® Forum Software