コード例 #1
0
ファイル: w32mutex-unix.c プロジェクト: markusbeth/mono
static void
thread_disown_mutex (MonoInternalThreadHandle internal, gpointer handle)
{
	gboolean removed;

	g_assert (mono_thread_internal_is_current_handle (internal));

	g_assert (MONO_HANDLE_GETVAL (internal, owned_mutexes));
	removed = g_ptr_array_remove (MONO_HANDLE_GETVAL (internal, owned_mutexes), handle);
	g_assert (removed);

	mono_w32handle_close (handle);
}
コード例 #2
0
static void
thread_disown_mutex (MonoInternalThread *internal, gpointer handle)
{
	gboolean removed;

	g_assert (mono_thread_internal_is_current (internal));

	g_assert (internal->owned_mutexes);
	removed = g_ptr_array_remove (internal->owned_mutexes, handle);
	g_assert (removed);

	mono_w32handle_close (handle);
}
コード例 #3
0
BOOL
mono_w32socket_transmit_file (SOCKET sock, gpointer file_handle, TRANSMIT_FILE_BUFFERS *buffers, guint32 flags, gboolean blocking)
{
	MonoThreadInfo *info;
	gpointer handle;
	gint file;
	gssize ret;
#if defined(HAVE_SENDFILE) && (defined(__linux__) || defined(DARWIN))
	struct stat statbuf;
#else
	gchar *buffer;
#endif

	handle = GUINT_TO_POINTER (sock);
	if (mono_w32handle_get_type (handle) != MONO_W32HANDLE_SOCKET) {
		mono_w32socket_set_last_error (WSAENOTSOCK);
		return FALSE;
	}

	/* Write the header */
	if (buffers != NULL && buffers->Head != NULL && buffers->HeadLength > 0) {
		ret = mono_w32socket_send (sock, buffers->Head, buffers->HeadLength, 0, FALSE);
		if (ret == SOCKET_ERROR)
			return FALSE;
	}

	info = mono_thread_info_current ();

	file = GPOINTER_TO_INT (file_handle);

#if defined(HAVE_SENDFILE) && (defined(__linux__) || defined(DARWIN))
	ret = fstat (file, &statbuf);
	if (ret == -1) {
		gint errnum = errno;
		mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
		return SOCKET_ERROR;
	}

	do {
#ifdef __linux__
		ret = sendfile (sock, file, NULL, statbuf.st_size);
#elif defined(DARWIN)
		/* TODO: header/tail could be sent in the 5th argument */
		/* TODO: Might not send the entire file for non-blocking sockets */
		ret = sendfile (file, sock, 0, &statbuf.st_size, NULL, 0);
#endif
	} while (ret != -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
#else
	buffer = g_malloc (SF_BUFFER_SIZE);

	do {
		do {
			ret = read (file, buffer, SF_BUFFER_SIZE);
		} while (ret == -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));

		if (ret == -1 || ret == 0)
			break;

		do {
			ret = send (sock, buffer, ret, 0); /* short sends? enclose this in a loop? */
		} while (ret == -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));
	} while (ret != -1 && errno == EINTR && !mono_thread_info_is_interrupt_state (info));

	g_free (buffer);
#endif

	if (ret == -1) {
		gint errnum = errno;
		mono_w32socket_set_last_error (mono_w32socket_convert_error (errnum));
		return FALSE;
	}

	/* Write the tail */
	if (buffers != NULL && buffers->Tail != NULL && buffers->TailLength > 0) {
		ret = mono_w32socket_send (sock, buffers->Tail, buffers->TailLength, 0, FALSE);
		if (ret == SOCKET_ERROR)
			return FALSE;
	}

	if ((flags & TF_DISCONNECT) == TF_DISCONNECT)
		mono_w32handle_close (handle);

	return TRUE;
}
コード例 #4
0
gboolean
mono_w32socket_close (SOCKET sock)
{
	return mono_w32handle_close (GINT_TO_POINTER (sock));
}
コード例 #5
0
ファイル: w32event-unix.c プロジェクト: mhutch/mono
gboolean
mono_w32event_close (gpointer handle)
{
	return mono_w32handle_close (handle);
}