#define LOGDEBUG(...)
/* define LOGDEBUG(...) g_message(__VA_ARGS__) */
+static void
+abort_syscall (gpointer data)
+{
+ MonoThreadInfo *info = data;
+
+ if (mono_threads_core_needs_abort_syscall ())
+ mono_threads_core_abort_syscall (info);
+}
+
static gint32
convert_family (MonoAddressFamily mono_family)
{
gpointer
ves_icall_System_Net_Sockets_Socket_Accept_internal (SOCKET sock, gint32 *error, gboolean blocking)
{
+ gboolean interrupted;
SOCKET newsock;
*error = 0;
+ mono_thread_info_install_interrupt (abort_syscall, mono_thread_info_current (), &interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return NULL;
+ }
+
MONO_PREPARE_BLOCKING;
#ifdef HOST_WIN32
MONO_FINISH_BLOCKING;
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return NULL;
+ }
+
if(newsock==INVALID_SOCKET) {
*error = WSAGetLastError ();
return(NULL);
MonoInternalThread *thread = mono_thread_internal_current ();
mono_pollfd *pfds;
int ret;
+ gboolean interrupted;
time_t start;
*error = 0;
start = time (NULL);
do {
+ mono_thread_info_install_interrupt (abort_syscall, mono_thread_info_current (), &interrupted);
+ if (interrupted) {
+ g_free (pfds);
+ *error = WSAEINTR;
+ return FALSE;
+ }
+
MONO_PREPARE_BLOCKING;
ret = mono_poll (pfds, 1, timeout);
MONO_FINISH_BLOCKING;
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ g_free (pfds);
+ *error = WSAEINTR;
+ return FALSE;
+ }
+
if (timeout > 0 && ret < 0) {
int err = errno;
int sec = time (NULL) - start;
struct sockaddr *sa;
socklen_t sa_size;
int ret;
-
+ gboolean interrupted;
+
*error = 0;
sa = create_sockaddr_from_object(sockaddr, &sa_size, error);
LOGDEBUG (g_message("%s: connecting to %s port %d", __func__, inet_ntoa(((struct sockaddr_in *)sa)->sin_addr), ntohs (((struct sockaddr_in *)sa)->sin_port)));
+ mono_thread_info_install_interrupt (abort_syscall, mono_thread_info_current (), &interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return;
+ }
+
MONO_PREPARE_BLOCKING;
ret = _wapi_connect (sock, sa, sa_size);
MONO_FINISH_BLOCKING;
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return;
+ }
+
if (ret == SOCKET_ERROR)
*error = WSAGetLastError ();
GUID trans_guid = WSAID_TRANSMITFILE;
LPFN_DISCONNECTEX _wapi_disconnectex = NULL;
LPFN_TRANSMITFILE _wapi_transmitfile = NULL;
+ gboolean interrupted;
*error = 0;
_wapi_transmitfile = NULL;
}
+ mono_thread_info_install_interrupt (abort_syscall, mono_thread_info_current (), &interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return;
+ }
+
MONO_PREPARE_BLOCKING;
if (_wapi_disconnectex != NULL) {
}
MONO_FINISH_BLOCKING;
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted)
+ *error = WSAEINTR;
}
gint32
guchar *buf;
gint32 alen;
int recvflags=0;
+ gboolean interrupted;
MonoInternalThread* curthread G_GNUC_UNUSED = mono_thread_internal_current ();
*error = 0;
return (0);
}
+ mono_thread_info_install_interrupt (abort_syscall, mono_thread_info_current (), &interrupted);
+ if (interrupted)
+ return 0;
+
MONO_PREPARE_BLOCKING;
#ifdef HOST_WIN32
MONO_FINISH_BLOCKING;
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return 0;
+ }
+
if(ret==SOCKET_ERROR) {
*error = WSAGetLastError ();
return(0);
ves_icall_System_Net_Sockets_Socket_Receive_array_internal (SOCKET sock, MonoArray *buffers, gint32 flags, gint32 *error)
{
int ret, count;
+ gboolean interrupted;
DWORD recv;
WSABUF *wsabufs;
DWORD recvflags = 0;
return(0);
}
+ mono_thread_info_install_interrupt (abort_syscall, mono_thread_info_current (), &interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return 0;
+ }
+
MONO_PREPARE_BLOCKING;
ret = WSARecv (sock, wsabufs, count, &recv, &recvflags, NULL, NULL);
MONO_FINISH_BLOCKING;
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return 0;
+ }
+
if (ret == SOCKET_ERROR) {
*error = WSAGetLastError ();
return 0;
int recvflags=0;
struct sockaddr *sa;
socklen_t sa_size;
+ gboolean interrupted;
*error = 0;
return (0);
}
+ mono_thread_info_install_interrupt (abort_syscall, mono_thread_info_current (), &interrupted);
+ if (interrupted) {
+ g_free(sa);
+ *error = WSAEINTR;
+ return 0;
+ }
+
MONO_PREPARE_BLOCKING;
ret = _wapi_recvfrom (sock, buf, count, recvflags, sa, &sa_size);
MONO_FINISH_BLOCKING;
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ g_free(sa);
+ *error = WSAEINTR;
+ return 0;
+ }
+
if(ret==SOCKET_ERROR) {
g_free(sa);
*error = WSAGetLastError ();
guchar *buf;
gint32 alen;
int sendflags=0;
+ gboolean interrupted;
*error = 0;
return (0);
}
+ mono_thread_info_install_interrupt (abort_syscall, mono_thread_info_current (), &interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return 0;
+ }
+
MONO_PREPARE_BLOCKING;
ret = _wapi_send (sock, buf, count, sendflags);
MONO_FINISH_BLOCKING;
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return 0;
+ }
+
if(ret==SOCKET_ERROR) {
*error = WSAGetLastError ();
return(0);
DWORD sent;
WSABUF *wsabufs;
DWORD sendflags = 0;
+ gboolean interrupted;
*error = 0;
return(0);
}
+ mono_thread_info_install_interrupt (abort_syscall, mono_thread_info_current (), &interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return 0;
+ }
+
MONO_PREPARE_BLOCKING;
ret = WSASend (sock, wsabufs, count, &sent, sendflags, NULL, NULL);
MONO_FINISH_BLOCKING;
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return 0;
+ }
+
if (ret == SOCKET_ERROR) {
*error = WSAGetLastError ();
return(0);
int sendflags=0;
struct sockaddr *sa;
socklen_t sa_size;
+ gboolean interrupted;
*error = 0;
return (0);
}
+ mono_thread_info_install_interrupt (abort_syscall, mono_thread_info_current (), &interrupted);
+ if (interrupted) {
+ g_free (sa);
+ *error = WSAEINTR;
+ return 0;
+ }
+
MONO_PREPARE_BLOCKING;
ret = _wapi_sendto (sock, buf, count, sendflags, sa, sa_size);
MONO_FINISH_BLOCKING;
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ g_free (sa);
+ *error = WSAEINTR;
+ return 0;
+ }
+
if(ret==SOCKET_ERROR) {
*error = WSAGetLastError ();
}
MonoArray *socks;
time_t start;
uintptr_t socks_size;
+ gboolean interrupted;
*error = 0;
timeout = (timeout >= 0) ? (timeout / 1000) : -1;
start = time (NULL);
do {
+ mono_thread_info_install_interrupt (abort_syscall, mono_thread_info_current (), &interrupted);
+ if (interrupted) {
+ g_free (pfds);
+ *error = WSAEINTR;
+ return;
+ }
+
MONO_PREPARE_BLOCKING;
ret = mono_poll (pfds, nfds, timeout);
MONO_FINISH_BLOCKING;
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ g_free (pfds);
+ *error = WSAEINTR;
+ return;
+ }
+
if (timeout > 0 && ret < 0) {
int err = errno;
int sec = time (NULL) - start;
ves_icall_System_Net_Sockets_Socket_Shutdown_internal(SOCKET sock, gint32 how, gint32 *error)
{
int ret;
+ gboolean interrupted;
*error = 0;
+ mono_thread_info_install_interrupt (abort_syscall, mono_thread_info_current (), &interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return;
+ }
+
MONO_PREPARE_BLOCKING;
/* Currently, the values for how (recv=0, send=1, both=2) match the BSD API */
MONO_FINISH_BLOCKING;
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ *error = WSAEINTR;
+ return;
+ }
+
if (ret == SOCKET_ERROR)
*error = WSAGetLastError ();
}
HANDLE file;
gint32 error;
gboolean ret;
+ gboolean interrupted;
TRANSMIT_FILE_BUFFERS buffers;
if (filename == NULL)
buffers.TailLength = mono_array_length (post_buffer);
}
+ mono_thread_info_install_interrupt (abort_syscall, mono_thread_info_current (), &interrupted);
+ if (interrupted) {
+ CloseHandle (file);
+ SetLastError (WSAEINTR);
+ return FALSE;
+ }
+
MONO_PREPARE_BLOCKING;
ret = TransmitFile (sock, file, 0, 0, NULL, &buffers, flags);
MONO_FINISH_BLOCKING;
+ mono_thread_info_uninstall_interrupt (&interrupted);
+ if (interrupted) {
+ CloseHandle (file);
+ SetLastError (WSAEINTR);
+ return FALSE;
+ }
+
MONO_PREPARE_BLOCKING;
CloseHandle (file);
return ret;
}
+gboolean
+ves_icall_System_Net_Sockets_Socket_SupportPortReuse (void)
+{
+#if defined (SO_REUSEPORT) || defined (HOST_WIN32)
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
void
mono_network_init(void)
{