Merge pull request #656 from LogosBible/collection_lock
authorAlex Rønne Petersen <alex@lycus.org>
Sat, 12 Apr 2014 13:40:23 +0000 (15:40 +0200)
committerAlex Rønne Petersen <alex@lycus.org>
Sat, 12 Apr 2014 13:40:23 +0000 (15:40 +0200)
Take shared file lock before collecting file share_info.

mono/io-layer/collection.c

index 9190d2d908707062bb63581e0946e65ab12f45a7..a42bbadcfe0b6827874a2e4c877597b0982527fd 100644 (file)
@@ -92,6 +92,9 @@ void _wapi_handle_collect (void)
        thr_ret = _wapi_handle_lock_shared_handles ();
        g_assert (thr_ret == 0);
        
+       thr_ret = _wapi_shm_sem_lock (_WAPI_SHARED_SEM_FILESHARE);
+       g_assert (thr_ret == 0);
+       
        DEBUG ("%s: (%d) Master set", __func__, _wapi_getpid ());
        
        /* If count has changed, someone else jumped in as master */
@@ -120,6 +123,9 @@ void _wapi_handle_collect (void)
                InterlockedIncrement ((gint32 *)&_wapi_shared_layout->collection_count);
        }
        
+       thr_ret = _wapi_shm_sem_unlock (_WAPI_SHARED_SEM_FILESHARE);
+       g_assert (thr_ret == 0);
+        
        _wapi_handle_unlock_shared_handles ();
 
        DEBUG ("%s: (%d) Collection done", __func__, _wapi_getpid ());