* Makefile (MCS) [PROFILE=default]: Force testing of 'mcs'.
[mono.git] / mono / io-layer / shared.c
index c47133e8eb50d022b602cc9b0b776447593e1d55..b0e828a222107e17c6c5f2dbb2ccf9ed4dc79d7b 100644 (file)
@@ -103,6 +103,7 @@ guchar *_wapi_shm_file (_wapi_shm_t type, guint32 segment)
        g_free (name);
 
        g_snprintf (file, _POSIX_PATH_MAX, "%s", filename);
+       g_free (filename);
                
        /* No need to check if the dir already exists or check
         * mkdir() errors, because on any error the open() call will
@@ -122,6 +123,7 @@ gpointer _wapi_shm_file_expand (gpointer mem, _wapi_shm_t type,
        int fd;
        gpointer new_mem;
        guchar *filename=_wapi_shm_file (type, segment);
+       int ret;
 
        if(old_len>=new_len) {
                return(mem);
@@ -144,12 +146,18 @@ gpointer _wapi_shm_file_expand (gpointer mem, _wapi_shm_t type,
                return(NULL);
        }
        
-       if(write (fd, "", 1)==-1) {
+       do {
+               ret=write (fd, "", 1);
+       }
+       while (ret==-1 && errno==EINTR);
+
+       if(ret==-1) {
                g_critical (G_GNUC_PRETTY_FUNCTION
                            ": shared file [%s] write error: %s", filename,
                            g_strerror (errno));
                return(NULL);
        }
+
        close (fd);
        
        new_mem=_wapi_shm_file_map (type, segment, NULL, NULL);
@@ -163,6 +171,7 @@ static int _wapi_shm_file_open (const guchar *filename, _wapi_shm_t type,
        int fd;
        struct stat statbuf;
        guint32 wanted_size = 0;
+       int ret;
        
        if(created) {
                *created=FALSE;
@@ -215,7 +224,12 @@ try_again:
                                return(-1);
                        }
                        
-                       if(write (fd, "", 1)==-1) {
+                       do {
+                               ret=write (fd, "", 1);
+                       }
+                       while (ret==-1 && errno==EINTR);
+                               
+                       if(ret==-1) {
                                g_critical (G_GNUC_PRETTY_FUNCTION ": shared file [%s] write error: %s", filename, g_strerror (errno));
                                close (fd);
                                unlink (filename);