Update of /cvsroot/mahogany/M/src/gui
In directory usw-pr-cvs1:/tmp/cvs-serv17182/src/gui

Modified Files:
        wxMApp.cpp 
Log Message:
use the username in the lock and IPC file names to avoid problems with multiple users 
using M concurrently

Index: wxMApp.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMApp.cpp,v
retrieving revision 1.241
retrieving revision 1.242
diff -b -u -2 -r1.241 -r1.242
--- wxMApp.cpp  15 Jun 2002 11:41:27 -0000      1.241
+++ wxMApp.cpp  4 Jul 2002 14:25:25 -0000       1.242
@@ -764,5 +764,12 @@
    // it could also be a bad idea as HOME is often NFS-mounted and creating
    // locks over NFS doesn't work well/at all
-   if ( !m_snglInstChecker->Create(".mahogany.lock", "/tmp") )
+   //
+   // NB: see comments in GetIPCSocket() about using wxGetUserId()
+   if ( !m_snglInstChecker->Create
+                            (
+                              wxString::Format(".mahogany-%s.lock",
+                                               wxGetUserId().c_str()),
+                              "/tmp"
+                            ) )
    {
       // this message is in English because translations were not loaded yet as
@@ -2275,8 +2282,29 @@
 // ----------------------------------------------------------------------------
 
-#define IPC_SOCKET "/tmp/.mahogany.ipc"
 #define IPC_TOPIC  "MRemote"
 
 // ----------------------------------------------------------------------------
+// IPC functions
+// ----------------------------------------------------------------------------
+
+// return the name of the IPC socket we use -- this is only really used under
+// Unix
+static String GetIPCSocket()
+{
+   static String s_socketName;
+   if ( s_socketName.empty() )
+   {
+      // we are using wxGetUserId() to allow multiple users to run multiple
+      // copies of Mahogany, each communicating via its own socket and the name
+      // seems to be better than UID as, although it seems unlikely, we might
+      // have the same user logged in from 2 different machines sharing the
+      // same /tmp directory
+      s_socketName.Printf("/tmp/.mahogany-%s.ipc", wxGetUserId().c_str());
+   }
+
+   return s_socketName;
+}
+
+// ----------------------------------------------------------------------------
 // IPC classes
 // ----------------------------------------------------------------------------
@@ -2355,5 +2383,5 @@
 
    m_serverIPC = new MAppIPCServer;
-   if ( !m_serverIPC->Create(IPC_SOCKET) )
+   if ( !m_serverIPC->Create(GetIPCSocket()) )
    {
       delete m_serverIPC;
@@ -2375,5 +2403,5 @@
 
    wxClient client;
-   wxConnectionBase *conn = client.MakeConnection("", IPC_SOCKET, IPC_TOPIC);
+   wxConnectionBase *conn = client.MakeConnection("", GetIPCSocket(), IPC_TOPIC);
    if ( !conn )
    {



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Caffeinated soap. No kidding.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to