]> granicus.if.org Git - vim/commitdiff
updated for version 7.2.392 v7.2.392
authorBram Moolenaar <Bram@vim.org>
Wed, 10 Mar 2010 15:12:48 +0000 (16:12 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 10 Mar 2010 15:12:48 +0000 (16:12 +0100)
Problem:    Netbeans hangs reading from a socket at the maximum block size.
Solution:   Use select() or poll(). (Xavier de Gaye)

src/if_xcmdsrv.c
src/netbeans.c
src/os_unixx.h
src/version.c
src/vim.h

index 4b291399dff5bf6ea478a9f7c2a607e605bf5d35..5412b35d44472c1b548cc4c3fb41973af0c2d8e8 100644 (file)
 #  include <X11/Xatom.h>
 # endif
 
-# if defined(HAVE_SYS_SELECT_H) && \
-       (!defined(HAVE_SYS_TIME_H) || defined(SYS_SELECT_WITH_SYS_TIME))
-#  include <sys/select.h>
-# endif
-
-# ifndef HAVE_SELECT
-#  ifdef HAVE_SYS_POLL_H
-#   include <sys/poll.h>
-#  else
-#   ifdef HAVE_POLL_H
-#    include <poll.h>
-#   endif
-#  endif
-# endif
-
 /*
  * This file provides procedures that implement the command server
  * functionality of Vim when in contact with an X11 server.
index 87e0edd14f0edf0ef594a16b18ce22e197b9d4a3..ed0cd05b64edb227ebdb50cbc8150250590f52ed 100644 (file)
@@ -735,6 +735,14 @@ messageFromNetbeans(gpointer clientData UNUSED,
     int                        readlen = 0;
 #ifndef FEAT_GUI_GTK
     static int         level = 0;
+#endif
+#ifdef HAVE_SELECT
+    struct timeval     tval;
+    fd_set             rfds;
+#else
+# ifdef HAVE_POLL
+    struct pollfd      fds;
+# endif
 #endif
 
     if (sd < 0)
@@ -755,9 +763,26 @@ messageFromNetbeans(gpointer clientData UNUSED,
            return;     /* out of memory! */
     }
 
-    /* Keep on reading for as long as there is something to read. */
+    /* Keep on reading for as long as there is something to read.
+     * Use select() or poll() to avoid blocking on a message that is exactly
+     * MAXMSGSIZE long. */
     for (;;)
     {
+#ifdef HAVE_SELECT
+       FD_ZERO(&rfds);
+        FD_SET(sd, &rfds);
+        tval.tv_sec = 0;
+        tval.tv_usec = 0;
+        if (select(sd + 1, &rfds, NULL, NULL, &tval) <= 0)
+            break;
+#else
+# ifdef HAVE_POLL
+       fds.fd = sd;
+       fds.events = POLLIN;
+        if (poll(&fds, 1, 0) <= 0)
+            break;
+# endif
+#endif
        len = sock_read(sd, buf, MAXMSGSIZE);
        if (len <= 0)
            break;      /* error or nothing more to read */
index 3dd254e9ada3a1741bee7e48c3cdac596cec6d7c..e46edcf59ad566b0b69af9420d3e7ba64f9047cb 100644 (file)
 #  include <sys/wait.h>
 # endif
 
-# if defined(HAVE_SYS_SELECT_H) && \
-       (!defined(HAVE_SYS_TIME_H) || defined(SYS_SELECT_WITH_SYS_TIME))
-#  include <sys/select.h>
-# endif
-
 # ifndef WEXITSTATUS
 #  ifdef HAVE_UNION_WAIT
 #   define WEXITSTATUS(stat_val) ((stat_val).w_T.w_Retcode)
 # include <string.h>
 #endif
 
-#ifndef HAVE_SELECT
-# ifdef HAVE_SYS_POLL_H
-#  include <sys/poll.h>
-# else
-#  ifdef HAVE_POLL_H
-#   include <poll.h>
-#  endif
-# endif
-#endif
-
 #ifdef HAVE_SYS_STREAM_H
 # include <sys/stream.h>
 #endif
index a635aad7ad757dbc7bed418c94ceefb96aa5fdff..fbe806bf6cc608d1f6075ec7cbfe1b2c9ddcaf6a 100644 (file)
@@ -681,6 +681,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    392,
 /**/
     391,
 /**/
index d22227cf990efd35a49956f047821d07c90191c3..b6b4e1e9be2321ee7d85f29d305e9218b7bda6bc 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -477,6 +477,23 @@ typedef unsigned long u8char_T;        /* long should be 32 bits or more */
 # include <stdarg.h>
 #endif
 
+# if defined(HAVE_SYS_SELECT_H) && \
+       (!defined(HAVE_SYS_TIME_H) || defined(SYS_SELECT_WITH_SYS_TIME))
+#  include <sys/select.h>
+# endif
+
+# ifndef HAVE_SELECT
+#  ifdef HAVE_SYS_POLL_H
+#   include <sys/poll.h>
+#   define HAVE_POLL
+#  else
+#   ifdef HAVE_POLL_H
+#    include <poll.h>
+#    define HAVE_POLL
+#   endif
+#  endif
+# endif
+
 /* ================ end of the header file puzzle =============== */
 
 /*