changeset 48545:538af265a4a7

(sys_write): Avoid non-blocking mode, which is not fully supported.
author Jason Rumney <jasonr@gnu.org>
date Mon, 25 Nov 2002 23:30:19 +0000
parents 25945a0f9ea5
children 12718f5f58aa
files src/w32.c
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32.c	Mon Nov 25 23:29:35 2002 +0000
+++ b/src/w32.c	Mon Nov 25 23:30:19 2002 +0000
@@ -3709,8 +3709,24 @@
 #ifdef HAVE_SOCKETS
   if (fd_info[fd].flags & FILE_SOCKET)
     {
+      unsigned long nblock = 0;
       if (winsock_lib == NULL) abort ();
+
+      /* TODO: implement select() properly so non-blocking I/O works. */
+      /* For now, make sure the write blocks.  */
+      if (fd_info[fd].flags & FILE_NDELAY)
+	pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock);
+
       nchars =  pfn_send (SOCK_HANDLE (fd), buffer, count, 0);
+
+      /* Set the socket back to non-blocking if it was before,
+	 for other operations that support it.  */
+      if (fd_info[fd].flags & FILE_NDELAY)
+	{
+	  nblock = 1;
+	  pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock);
+	}
+
       if (nchars == SOCKET_ERROR)
         {
 	  DebPrint(("sys_read.send failed with error %d on socket %ld\n",