Thomas Weidenmueller wrote:
ion@svn.reactos.com wrote:
Remove bogus error message. It is normal for Mutex creation to fail since the Object will alredy exist after the first time it's created Modified: trunk/reactos/lib/rpcrt4/rpcrt4_main.c _____ Modified: trunk/reactos/lib/rpcrt4/rpcrt4_main.c --- trunk/reactos/lib/rpcrt4/rpcrt4_main.c 2005-04-20 12:46:39 UTC (rev 14710) +++ trunk/reactos/lib/rpcrt4/rpcrt4_main.c 2005-04-20 12:52:13 UTC (rev 14711) @@ -152,8 +152,6 @@
case DLL_PROCESS_ATTACH: DisableThreadLibraryCalls(hinstDLL); master_mutex = CreateMutexA( NULL, FALSE,RPCSS_MASTER_MUTEX_NAME);
if (!master_mutex)ERR("Failed to create master mutex\n"); break;case DLL_PROCESS_DETACH:
Ros-diffs mailing list Ros-diffs@reactos.com http://reactos.com:8080/mailman/listinfo/ros-diffs
IMO you should open the mutex if creating it failed, otherwise master_mutex is NULL...
I actually think the code as originally written was correct. (Although if ERR() is simply a debug tracing macro, more error handling is probably needed.)
Regardless of whether the mutex is newly created or pre-existing, CreateMutex() will return a handle to it.
In the case of a pre-existing mutex, the handle to the existing object is returned.
If it is important to know whether the mutex was created or not, GetLastError() can be checked in the success case for the value ERROR_ALREADY_EXISTS (which in this case is not really an error, since the function succeeded.)
If CreateMutex() returns NULL, it failed for some other reason (than that the mutex already existed, since CreateMutex doesn't fail in this case.)
Calling OpenMutex would not be productive in this case.
Thanks,
Joseph