瀏覽代碼

2002-09-30 Dick Porter <[email protected]>

	* sockets.c (ioctlsocket): Set non-blocking mode in a better way,
	with fcntl.

svn path=/trunk/mono/; revision=7896
Dick Porter 23 年之前
父節點
當前提交
1c4c28a73b
共有 3 個文件被更改,包括 23 次插入1 次删除
  1. 5 0
      mono/io-layer/ChangeLog
  2. 15 1
      mono/io-layer/sockets.c
  3. 3 0
      mono/metadata/socket-io.c

+ 5 - 0
mono/io-layer/ChangeLog

@@ -1,3 +1,8 @@
+2002-09-30  Dick Porter  <[email protected]>
+
+	* sockets.c (ioctlsocket): Set non-blocking mode in a better way,
+	with fcntl.
+
 2002-09-27  Dick Porter  <[email protected]>
 
 	* semaphores.c: Only include semaphore.h if it's present. Patch

+ 15 - 1
mono/io-layer/sockets.c

@@ -22,6 +22,7 @@
 #include <sys/sockio.h>    /* defines SIOCATMARK */
 #endif
 #include <unistd.h>
+#include <fcntl.h>
 
 #ifndef HAVE_MSG_NOSIGNAL
 #include <signal.h>
@@ -1106,7 +1107,20 @@ int ioctlsocket(guint32 handle, gint32 command, gpointer arg)
 		return(SOCKET_ERROR);
 	}
 
-	ret=ioctl(socket_private_handle->fd, command, arg);
+#ifdef O_NONBLOCK
+	/* This works better than ioctl(...FIONBIO...) on Linux (it causes
+	 * connect to return EINPROGRESS, but the ioctl doesn't seem to)
+	 */
+	if(command==FIONBIO) {
+		ret=fcntl(socket_private_handle->fd, F_GETFL, 0);
+		if(ret!=-1) {
+			ret=fcntl(socket_private_handle->fd, F_SETFL, ret|O_NONBLOCK);
+		}
+	} else
+#endif /* O_NONBLOCK */
+	{
+		ret=ioctl(socket_private_handle->fd, command, arg);
+	}
 	if(ret==-1) {
 #ifdef DEBUG
 		g_message(G_GNUC_PRETTY_FUNCTION ": ioctl error: %s",

+ 3 - 0
mono/metadata/socket-io.c

@@ -519,7 +519,10 @@ void ves_icall_System_Net_Sockets_Socket_Close_internal(SOCKET sock)
 
 gint32 ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal(void)
 {
+#ifdef DEBUG
 	g_message(G_GNUC_PRETTY_FUNCTION ": returning %d", WSAGetLastError());
+#endif
+
 	return(WSAGetLastError());
 }