2006-03-27 Dick Porter <dick@ximian.com>
authorDick Porter <dick@acm.org>
Mon, 27 Mar 2006 11:37:39 +0000 (11:37 -0000)
committerDick Porter <dick@acm.org>
Mon, 27 Mar 2006 11:37:39 +0000 (11:37 -0000)
        * shared.c (_wapi_shm_file_open): Break out of a loop if the
        shared file is smaller than expected.  (We loop a few times in
        case another process is in the middle of creating the file.)

svn path=/trunk/mono/; revision=58566

mono/io-layer/ChangeLog
mono/io-layer/shared.c

index 3a8de9d05de82339ed3351d28aeb0c59effc0ac9..0932736a458a87b7b4b86c2dcb8236d63dab7e2f 100644 (file)
@@ -1,3 +1,9 @@
+2006-03-27  Dick Porter  <dick@ximian.com>
+
+       * shared.c (_wapi_shm_file_open): Break out of a loop if the
+       shared file is smaller than expected.  (We loop a few times in
+       case another process is in the middle of creating the file.)
+
 2006-03-22  Dick Porter  <dick@ximian.com>
 
        * handles.c:
index 3e92c3436e00d0caf2c3e0cd0e7578623c84bf8e..be2a1eeb24b28ad3534e2c8a7ae735560fc6d13f 100644 (file)
@@ -104,10 +104,18 @@ static int _wapi_shm_file_open (const guchar *filename, guint32 wanted_size)
 {
        int fd;
        struct stat statbuf;
-       int ret;
+       int ret, tries = 0;
        gboolean created = FALSE;
        
 try_again:
+       if (tries++ > 10) {
+               /* Just give up */
+               return (-1);
+       } else if (tries > 5) {
+               /* Break out of a loop */
+               unlink (filename);
+       }
+       
        /* No O_CREAT yet, because we need to initialise the file if
         * we have to create it.
         */
@@ -195,6 +203,7 @@ try_again:
                        return(-1);
                } else {
                        /* We didn't create it, so just try opening it again */
+                       _wapi_handle_spin (100);
                        goto try_again;
                }
        }