2006-12-11 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mono / io-layer / shared.c
index f57a972d544d32d77a414b548748cf19faeb7265..b1f764436f37149821e8cb3b95f1d1cb292ae5a3 100644 (file)
 
 #undef DEBUG
 
-static guchar *_wapi_shm_file (_wapi_shm_t type)
+static gchar *_wapi_shm_file (_wapi_shm_t type)
 {
-       static guchar file[_POSIX_PATH_MAX];
-       guchar *name = NULL, *filename, *dir, *wapi_dir;
+       static gchar file[_POSIX_PATH_MAX];
+       gchar *name = NULL, *filename, *dir, *wapi_dir;
        gchar machine_name[256];
        const gchar *fake_name;
        struct utsname ubuf;
@@ -43,6 +43,9 @@ static guchar *_wapi_shm_file (_wapi_shm_t type)
        if (ret == -1) {
                ubuf.machine[0] = '\0';
                ubuf.sysname[0] = '\0';
+       } else {
+               g_strdelimit (ubuf.sysname, "/", '_');
+               g_strdelimit (ubuf.machine, "/", '_');
        }
 
        fake_name = g_getenv ("MONO_SHARED_HOSTNAME");
@@ -100,7 +103,7 @@ static guchar *_wapi_shm_file (_wapi_shm_t type)
        return(file);
 }
 
-static int _wapi_shm_file_open (const guchar *filename, guint32 wanted_size)
+static int _wapi_shm_file_open (const gchar *filename, guint32 wanted_size)
 {
        int fd;
        struct stat statbuf;
@@ -223,7 +226,7 @@ gpointer _wapi_shm_attach (_wapi_shm_t type)
        gpointer shm_seg;
        int fd;
        struct stat statbuf;
-       guchar *filename=_wapi_shm_file (type);
+       gchar *filename=_wapi_shm_file (type);
        guint32 size;
        
        switch(type) {
@@ -289,12 +292,11 @@ void _wapi_shm_semaphores_init ()
        for (i = 0; i < _WAPI_SHARED_SEM_COUNT; i++) {
                def_vals[i] = 1;
        }
-#ifdef NEXT_VERSION_INC
+
        /* Process count must start at '0' - the 1 for all the others
         * sets the semaphore to "unlocked"
         */
        def_vals[_WAPI_SHARED_SEM_PROCESS_COUNT] = 0;
-#endif
        
        defs.array = def_vals;
        
@@ -435,19 +437,9 @@ void _wapi_shm_semaphores_remove (void)
        
        proc_count = semctl (_wapi_sem_id, _WAPI_SHARED_SEM_PROCESS_COUNT,
                             GETVAL);
-#ifdef NEXT_VERSION_INC
+
        g_assert (proc_count > 0);
        if (proc_count == 1) {
-#else
-       /* Compatibility - the semaphore was initialised to '1' (which
-        * normally means 'unlocked'.  Instead of fixing that right
-        * now, which would mean a shared file version increment, just
-        * cope with the value starting too high for now.  Fix this
-        * next time I have to change the file version.
-        */
-       g_assert (proc_count > 1);
-       if (proc_count == 2) {
-#endif
                /* Just us, so blow away the semaphores and the shared
                 * files
                 */