Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

call to waitForSingleObject() inside DllMain()

10 views
Skip to first unread message

asno...@gmail.com

unread,
Nov 22, 2009, 3:05:00 AM11/22/09
to
I have an in-proc server that is initializing a 'logger object' inside
DllMain(). This 'logger object' is implemented inside regular DLL
using C++, and there are no threads or COM inside Logger.dll. This
logger.dll, has a named mutex, based on log file name, which it
acquires before writing to log-file. Mutex is needed because more than
one process write to same file through same binary(Logger.dll).

In-proc server is FTM. Multiple instances of this in-proc server could
be running at same time. In-proc server's DLL is calling Logger.dll,
and logger.dll is in turn calling waitForSingleObject(). Is there a
chance for dead-lock?
If so how can I prevent it?


Inproc.dll
--------------

CLogLibrary gblLogger; //exported from Logger.dll
DllMain()
{
if(DLL_ATTACH)
{
gblLogger.Initialize( "C:\\", "my.log");
}
}

Logger.dll
---------------

CLogger::Initialize( dir, file)
{
CreateMutex(0,false,file); //creating mutex using Filename as name.
WaitForSingleObjct()
{
CreateFile(); //write to log file
WriteFile();
ReleaseMutex();
}
CloseHandle();
}


Thanks
Ramesh

0 new messages