The messageFromNetbeans() functions call sock_read() with a socket
opened in blocking mode.  When the received data is exactly
MAXMSGSIZE, the next read() in the loop will block until the IDE sends
data or disconnects the socket. If the IDE is expecting an answer from
vim at this time, then vim hangs indefinetely.

Test case:
----------
1) run vim in netbeans debug mode and add the following statement
   after the sock_read() call:

    nbdebug(("got length: %d\n", len));

2) start clewn in debug mode with '-d', edit a file in vim and run the
   following command in clewn:

    (gdb) # 2 insert "01234567890123456789012345678901234567890123456789"

3) the netbeans.log file indicates that the length of the above
   function sent on the socket is 65, so change the definition of
   MAXMSGSIZE in netbeans.c to:

    #define MAXMSGSIZE 65

4) repeat step 2 and check that vim is hanged


Attached is a patch on vim-7.2.385 that fixes this problem on unix.

I am not familiar enough with Windows but it seems that the patch may
also correct the problem on Windows when 'HAVE_SELECT' is defined in
Make_ming.mak and Make_mvc.mak.


Xavier

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/auto/configure b/src/auto/configure
--- a/src/auto/configure
+++ b/src/auto/configure
@@ -14044,7 +14044,7 @@
 	setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
 	sigvec strcasecmp strerror strftime stricmp strncasecmp \
 	strnicmp strpbrk strtol tgetent towlower towupper iswupper \
-	usleep utime utimes
+	usleep utime utimes poll
 do
 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
diff --git a/src/config.h.in b/src/config.h.in
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -165,6 +165,7 @@
 #undef HAVE_READLINK
 #undef HAVE_RENAME
 #undef HAVE_SELECT
+#undef HAVE_POLL
 #undef HAVE_SELINUX
 #undef HAVE_SETENV
 #undef HAVE_SETPGID
diff --git a/src/netbeans.c b/src/netbeans.c
--- a/src/netbeans.c
+++ b/src/netbeans.c
@@ -736,6 +736,19 @@
 #ifndef FEAT_GUI_GTK
     static int		level = 0;
 #endif
+#ifdef HAVE_SELECT
+    struct timeval tval;
+    fd_set rfds;
+
+    FD_ZERO(&rfds);
+#else
+# ifdef HAVE_POLL
+    struct pollfd fds;
+
+    fds.fd = sd;
+    fds.events = POLLIN;
+# endif
+#endif
 
     if (sd < 0)
     {
@@ -758,6 +771,18 @@
     /* Keep on reading for as long as there is something to read. */
     for (;;)
     {
+#ifdef HAVE_SELECT
+        FD_SET(sd, &rfds);
+        tval.tv_sec = 0;
+        tval.tv_usec = 0;
+        if (select(sd + 1, &rfds, NULL, NULL, &tval) <= 0)
+#else
+# ifdef HAVE_POLL
+        if (poll(&fds, 1, 0) <= 0)
+# endif
+#endif
+            break;
+
 	len = sock_read(sd, buf, MAXMSGSIZE);
 	if (len <= 0)
 	    break;	/* error or nothing more to read */

Raspunde prin e-mail lui