]> git.eshelyaron.com Git - emacs.git/commitdiff
(sys_write): Avoid non-blocking mode, which is not fully
authorJason Rumney <jasonr@gnu.org>
Mon, 25 Nov 2002 23:30:19 +0000 (23:30 +0000)
committerJason Rumney <jasonr@gnu.org>
Mon, 25 Nov 2002 23:30:19 +0000 (23:30 +0000)
supported.

src/w32.c

index c80c4232bc6a78ebd3c450a9eff3d671022f024d..c7537ec71941ba1036bc7133f6aae01fdd0d8f49 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -3709,8 +3709,24 @@ sys_write (int fd, const void * buffer, unsigned int count)
 #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",