none
Confusion on system mutex-es RRS feed

  • Question

  • <o:p></o:p>


    Hi .. hope I am in the right place. I have been trying with mutexes trying to get IPC working on WS2012. I have a setup of a windows service and IIS running several WCF connected services. When I start the windows service it executes the following code:

    Var _mutexname = @"Global\RETAILPLAZA_IPC_" + suffix; (very long name) …

    var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);

                        var mutexsecurity = new MutexSecurity();

                        mutexsecurity.AddAccessRule(new MutexAccessRule(sid, MutexRights.FullControl, AccessControlType.Allow));

                        mutexsecurity.AddAccessRule(new MutexAccessRule(sid, MutexRights.ChangePermissions, AccessControlType.Allow));

                        mutexsecurity.AddAccessRule(new MutexAccessRule(sid, MutexRights.Delete, AccessControlType.Allow));

                        //

                        MessageText.Show(MessageEntryType.Information, "Creating Mutex {0}", _mutexname);

                        _mutex = new Mutex(true, _mutexname, out _mutexcreated, mutexsecurity);

    The mutex is located at a later stadium using:

    mutex = Mutex.OpenExisting(_mutexname);

                    mutex.WaitOne();

                    mutex.ReleaseMutex(); 

    This works within the same process (address space ???) within Visual studio whilst debugging. Which is the desired result.

    Undesired results are: (handle does not exist …)

    1. It does not work when you run the application from the command line      (administrator mode on). In this case you are within the same process/virtual      address space
    2. It does not work when trying to share storage between IIS and the      windows service.

    Where do I go wrong ?? I get a feeling it is either to do with the naming of the Mutex, or otherwise security definitions. At any rate the available information on the net/msdn is very sparse ….

    Any hel appreciated … Steve    

    sid = newSecurityIdentifier(WellKnownSidType.WorldSid, null);

    varsid = newSecurityIdentifier(WellKnownSidType.WorldSid, null);

                       

    varmtexsecurity = newMutexSecurity();

                        mutexsecurity.AddAccessRule(

    newMutexAccessRule(sid, MutexRights.FullControl, AccessControlType.Allow));

                        mutexsecurity.AddAccessRule(

    newMutexAccessRule(sid, MutexRights.ChangePermissions, AccessControlType.Allow));

             

               

    Thursday, October 29, 2015 7:27 PM

Answers

All replies

  • Hi ... sorry for the rubbish at the end. Just as an afterthought ... is it actually possible to perform IPC between any given processes on the same WS2012 machine ??

    ths again ....

    Thursday, October 29, 2015 7:44 PM
  • Hi StevieWright,

    >>It does not work when you run the application from the command line

    Any exceptions occured?

    >>It does not work when trying to share storage between IIS and the windows service.

    Mutex is used for interprocess synchronization. It can't work for sharing storage between multi processes.

    >>is it actually possible to perform IPC between any given processes on the same WS2012 machine

    Of course yes. You could use share file/MSMQ/any network protocol(HTTP/TCP) to do it.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 30, 2015 2:15 AM
    Moderator
  • Try a simpler way: use a similar ‘new Mutex’ without security arguments (instead of OpenExisting too) and also examine the created objects using Process Explorer tool (https://social.msdn.microsoft.com/Forums/vstudio/en-US/47e6ee95-f2dc-45cd-b456-0e755b99bb52).

    Make sure that the “Global\...” name is the same. In some cases, also make sure that the mutex, which is created by main service, is kept in a member or global variable (not in a local variable) which is not destroyed by “Garbage Collector”.

    Saturday, October 31, 2015 9:17 AM