#include <mono/io-layer/shared.h>
#include <mono/io-layer/collection.h>
#include <mono/io-layer/process-private.h>
-#include <mono/io-layer/critical-section-private.h>
#include <mono/utils/mono-mutex.h>
#undef DEBUG_REFS
* 4MB array.
*/
static GHashTable *file_share_hash;
-static CRITICAL_SECTION file_share_hash_mutex;
+static mono_mutex_t file_share_hash_mutex;
-#define file_share_hash_lock() EnterCriticalSection (&file_share_hash_mutex)
-#define file_share_hash_unlock() LeaveCriticalSection (&file_share_hash_mutex)
+#define file_share_hash_lock() mono_mutex_lock (&file_share_hash_mutex)
+#define file_share_hash_unlock() mono_mutex_unlock (&file_share_hash_mutex)
guint32 _wapi_fd_reserve;
if (file_share_hash) {
g_hash_table_destroy (file_share_hash);
- DeleteCriticalSection (&file_share_hash_mutex);
+ mono_mutex_destroy (&file_share_hash_mutex);
}
for (i = 0; i < _WAPI_PRIVATE_MAX_SLOTS; ++i)
_wapi_error_cleanup ();
_wapi_thread_cleanup ();
+ wapi_processes_cleanup ();
}
static void _wapi_handle_init_shared (struct _WapiHandleShared *handle,
}
}
+static size_t _wapi_handle_struct_size (WapiHandleType type)
+{
+ size_t type_size;
+
+ switch (type) {
+ case WAPI_HANDLE_FILE: case WAPI_HANDLE_CONSOLE: case WAPI_HANDLE_PIPE:
+ type_size = sizeof (struct _WapiHandle_file);
+ break;
+ case WAPI_HANDLE_THREAD:
+ type_size = sizeof (struct _WapiHandle_thread);
+ break;
+ case WAPI_HANDLE_SEM:
+ type_size = sizeof (struct _WapiHandle_sem);
+ break;
+ case WAPI_HANDLE_MUTEX:
+ type_size = sizeof (struct _WapiHandle_mutex);
+ break;
+ case WAPI_HANDLE_EVENT:
+ type_size = sizeof (struct _WapiHandle_event);
+ break;
+ case WAPI_HANDLE_SOCKET:
+ type_size = sizeof (struct _WapiHandle_socket);
+ break;
+ case WAPI_HANDLE_FIND:
+ type_size = sizeof (struct _WapiHandle_find);
+ break;
+ case WAPI_HANDLE_PROCESS:
+ type_size = sizeof (struct _WapiHandle_process);
+ break;
+ case WAPI_HANDLE_NAMEDMUTEX:
+ type_size = sizeof (struct _WapiHandle_namedmutex);
+ break;
+ case WAPI_HANDLE_NAMEDSEM:
+ type_size = sizeof (struct _WapiHandle_namedsem);
+ break;
+ case WAPI_HANDLE_NAMEDEVENT:
+ type_size = sizeof (struct _WapiHandle_namedevent);
+ break;
+
+ default:
+ g_error ("Unknown WapiHandleType: %d\n", type);
+ }
+
+ return type_size;
+}
+
static void _wapi_handle_init (struct _WapiHandleUnshared *handle,
WapiHandleType type, gpointer handle_specific)
{
int thr_ret;
+ int type_size;
g_assert (_wapi_has_shut_down == FALSE);
g_assert (thr_ret == 0);
if (handle_specific != NULL) {
+ type_size = _wapi_handle_struct_size (type);
memcpy (&handle->u, handle_specific,
- sizeof (handle->u));
+ type_size);
}
}
}
*/
if (!file_share_hash) {
file_share_hash = g_hash_table_new_full (wapi_share_info_hash, wapi_share_info_equal, NULL, g_free);
- InitializeCriticalSection (&file_share_hash_mutex);
+ mono_mutex_init_recursive (&file_share_hash_mutex);
}
tmp.device = device;