#include <pthread.h>
#include <errno.h>
#include <unistd.h>
+#include <signal.h>
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
#include <mono/io-layer/wapi.h>
#include <mono/io-layer/wapi-private.h>
#include <mono/io-layer/handles-private.h>
-#include <mono/io-layer/mono-mutex.h>
#include <mono/io-layer/misc-private.h>
#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
#if 0
}
-static mono_mutex_t scan_mutex = MONO_MUTEX_INITIALIZER;
+static mono_mutex_t scan_mutex;
static void handle_cleanup (void)
{
for(i = SLOT_INDEX (0); _wapi_private_handles[i] != NULL; i++) {
for(j = SLOT_OFFSET (0); j < _WAPI_HANDLE_INITIAL_COUNT; j++) {
struct _WapiHandleUnshared *handle_data = &_wapi_private_handles[i][j];
- int type = handle_data->type;
gpointer handle = GINT_TO_POINTER (i*_WAPI_HANDLE_INITIAL_COUNT+j);
-
- if (_WAPI_SHARED_HANDLE (type)) {
- if (type == WAPI_HANDLE_THREAD) {
- /* Special-case thread handles
- * because they need extra
- * cleanup. This also avoids
- * a race condition between
- * the application exit and
- * the finalizer thread - if
- * it finishes up between now
- * and actual app termination
- * it will find all its handle
- * details have been blown
- * away, so this sets those
- * anyway.
- */
- g_assert (0); /*This condition is freaking impossible*/
- _wapi_thread_set_termination_details (handle, 0);
- }
- }
-
+
for(k = handle_data->ref; k > 0; k--) {
DEBUG ("%s: unreffing %s handle %p", __func__, _wapi_handle_typename[type], handle);
if (_wapi_shm_enabled ())
_wapi_collection_init ();
#endif
+ _wapi_io_init ();
+ mono_mutex_init (&scan_mutex);
_wapi_global_signal_handle = _wapi_handle_new (WAPI_HANDLE_EVENT, NULL);
_wapi_global_signal_cond = &_WAPI_PRIVATE_HANDLES (GPOINTER_TO_UINT (_wapi_global_signal_handle)).signal_cond;
_wapi_global_signal_mutex = &_WAPI_PRIVATE_HANDLES (GPOINTER_TO_UINT (_wapi_global_signal_handle)).signal_mutex;
+
/* Using g_atexit here instead of an explicit function call in
* a cleanup routine lets us cope when a third-party library
* calls exit (eg if an X client loses the connection to its
_wapi_has_shut_down = TRUE;
- _wapi_critical_section_cleanup ();
_wapi_error_cleanup ();
_wapi_thread_cleanup ();
}
thr_ret = pthread_cond_init (&handle->signal_cond, NULL);
g_assert (thr_ret == 0);
- thr_ret = mono_mutex_init (&handle->signal_mutex, NULL);
+ thr_ret = mono_mutex_init (&handle->signal_mutex);
g_assert (thr_ret == 0);
if (handle_specific != NULL) {
*/
static void _wapi_handle_check_share_by_pid (struct _WapiFileShare *share_info)
{
+#if defined(__native_client__)
+ g_assert_not_reached ();
+#else
if (kill (share_info->opened_by_pid, 0) == -1 &&
(errno == ESRCH ||
errno == EPERM)) {
_wapi_free_share_info (share_info);
}
+#endif
}
#ifdef __linux__