#include <glib.h>
#include <string.h>
#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <errno.h>
#include <mono/metadata/object.h>
#include <mono/metadata/threadpool-internals.h>
#include <mono/metadata/domain-internals.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
}
#endif
-#ifndef PLATFORM_WIN32
- /* .net seems to set this by default for SOCK_STREAM,
- * not for SOCK_DGRAM (see bug #36322)
- *
- * It seems winsock has a rather different idea of what
- * SO_REUSEADDR means. If it's set, then a new socket can be
- * bound over an existing listening socket. There's a new
- * windows-specific option called SO_EXCLUSIVEADDRUSE but
- * using that means the socket MUST be closed properly, or a
- * denial of service can occur. Luckily for us, winsock
- * behaves as though any other system would when SO_REUSEADDR
- * is true, so we don't need to do anything else here. See
- * bug 53992.
- */
- {
- int ret, true = 1;
-
- ret = _wapi_setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &true, sizeof (true));
- if(ret==SOCKET_ERROR) {
- *error = WSAGetLastError ();
-
- closesocket(sock);
- return(NULL);
- }
- }
-#endif
-
return(GUINT_TO_POINTER (sock));
}
thread = mono_thread_current ();
}
- mono_monitor_enter (thread->synch_lock);
- leave = ((thread->state & ThreadState_AbortRequested) != 0 ||
- (thread->state & ThreadState_StopRequested) != 0);
- mono_monitor_exit (thread->synch_lock);
+ leave = mono_thread_test_state (thread, ThreadState_AbortRequested | ThreadState_StopRequested);
if (leave != 0) {
g_free (pfds);
if (thread == NULL)
thread = mono_thread_current ();
- mono_monitor_enter (thread->synch_lock);
- leave = ((thread->state & ThreadState_AbortRequested) != 0 ||
- (thread->state & ThreadState_StopRequested) != 0);
- mono_monitor_exit (thread->synch_lock);
+ leave = mono_thread_test_state (thread, ThreadState_AbortRequested | ThreadState_StopRequested);
+
if (leave != 0) {
g_free (pfds);
*sockets = NULL;
/* No idea why .net uses a 64bit type to hold a 32bit value...
*
- * Internal value of IPAddess is in Network Order, there is no need
- * to call htonl here.
+ * Internal value of IPAddess is in little-endian order
*/
- inaddr.s_addr=(guint32)*(guint64 *)(((char *)ipaddr)+field->offset);
+ inaddr.s_addr=GUINT_FROM_LE ((guint32)*(guint64 *)(((char *)ipaddr)+field->offset));
return(inaddr);
}
}
if(family == AF_INET) {
+#if HAVE_SOCKADDR_IN_SIN_LEN
+ saddr.sin_len = sizeof (saddr);
+#endif
if(getnameinfo ((struct sockaddr*)&saddr, sizeof(saddr),
hostname, sizeof(hostname), NULL, 0,
flags) != 0) {
return(FALSE);
}
} else if(family == AF_INET6) {
+#if HAVE_SOCKADDR_IN6_SIN_LEN
+ saddr6.sin6_len = sizeof (saddr6);
+#endif
if(getnameinfo ((struct sockaddr*)&saddr6, sizeof(saddr6),
hostname, sizeof(hostname), NULL, 0,
flags) != 0) {