90b7d6d
To: vim-dev@vim.org
90b7d6d
Subject: Patch 7.2.392
90b7d6d
Fcc: outbox
90b7d6d
From: Bram Moolenaar <Bram@moolenaar.net>
90b7d6d
Mime-Version: 1.0
90b7d6d
Content-Type: text/plain; charset=UTF-8
90b7d6d
Content-Transfer-Encoding: 8bit
90b7d6d
------------
90b7d6d
90b7d6d
Patch 7.2.392
90b7d6d
Problem:    Netbeans hangs reading from a socket at the maximum block size.
90b7d6d
Solution:   Use select() or poll(). (Xavier de Gaye)
90b7d6d
Files:	    src/vim.h, src/os_unixx.h, src/if_xcmdsrv.c, src/netbeans.c
90b7d6d
90b7d6d
90b7d6d
*** ../vim-7.2.391/src/vim.h	2010-03-02 15:55:51.000000000 +0100
90b7d6d
--- src/vim.h	2010-03-10 15:14:03.000000000 +0100
90b7d6d
***************
90b7d6d
*** 477,482 ****
90b7d6d
--- 477,499 ----
90b7d6d
  # include <stdarg.h>
90b7d6d
  #endif
90b7d6d
  
90b7d6d
+ # if defined(HAVE_SYS_SELECT_H) && \
90b7d6d
+ 	(!defined(HAVE_SYS_TIME_H) || defined(SYS_SELECT_WITH_SYS_TIME))
90b7d6d
+ #  include <sys/select.h>
90b7d6d
+ # endif
90b7d6d
+ 
90b7d6d
+ # ifndef HAVE_SELECT
90b7d6d
+ #  ifdef HAVE_SYS_POLL_H
90b7d6d
+ #   include <sys/poll.h>
90b7d6d
+ #   define HAVE_POLL
90b7d6d
+ #  else
90b7d6d
+ #   ifdef HAVE_POLL_H
90b7d6d
+ #    include <poll.h>
90b7d6d
+ #    define HAVE_POLL
90b7d6d
+ #   endif
90b7d6d
+ #  endif
90b7d6d
+ # endif
90b7d6d
+ 
90b7d6d
  /* ================ end of the header file puzzle =============== */
90b7d6d
  
90b7d6d
  /*
90b7d6d
*** ../vim-7.2.391/src/os_unixx.h	2006-03-25 22:48:00.000000000 +0100
90b7d6d
--- src/os_unixx.h	2010-03-10 15:14:49.000000000 +0100
90b7d6d
***************
90b7d6d
*** 28,38 ****
90b7d6d
  #  include <sys/wait.h>
90b7d6d
  # endif
90b7d6d
  
90b7d6d
- # if defined(HAVE_SYS_SELECT_H) && \
90b7d6d
- 	(!defined(HAVE_SYS_TIME_H) || defined(SYS_SELECT_WITH_SYS_TIME))
90b7d6d
- #  include <sys/select.h>
90b7d6d
- # endif
90b7d6d
- 
90b7d6d
  # ifndef WEXITSTATUS
90b7d6d
  #  ifdef HAVE_UNION_WAIT
90b7d6d
  #   define WEXITSTATUS(stat_val) ((stat_val).w_T.w_Retcode)
90b7d6d
--- 28,33 ----
90b7d6d
***************
90b7d6d
*** 65,80 ****
90b7d6d
  # include <string.h>
90b7d6d
  #endif
90b7d6d
  
90b7d6d
- #ifndef HAVE_SELECT
90b7d6d
- # ifdef HAVE_SYS_POLL_H
90b7d6d
- #  include <sys/poll.h>
90b7d6d
- # else
90b7d6d
- #  ifdef HAVE_POLL_H
90b7d6d
- #   include <poll.h>
90b7d6d
- #  endif
90b7d6d
- # endif
90b7d6d
- #endif
90b7d6d
- 
90b7d6d
  #ifdef HAVE_SYS_STREAM_H
90b7d6d
  # include <sys/stream.h>
90b7d6d
  #endif
90b7d6d
--- 60,65 ----
90b7d6d
*** ../vim-7.2.391/src/if_xcmdsrv.c	2009-05-16 17:29:37.000000000 +0200
90b7d6d
--- src/if_xcmdsrv.c	2010-03-10 15:14:09.000000000 +0100
90b7d6d
***************
90b7d6d
*** 21,41 ****
90b7d6d
  #  include <X11/Xatom.h>
90b7d6d
  # endif
90b7d6d
  
90b7d6d
- # if defined(HAVE_SYS_SELECT_H) && \
90b7d6d
- 	(!defined(HAVE_SYS_TIME_H) || defined(SYS_SELECT_WITH_SYS_TIME))
90b7d6d
- #  include <sys/select.h>
90b7d6d
- # endif
90b7d6d
- 
90b7d6d
- # ifndef HAVE_SELECT
90b7d6d
- #  ifdef HAVE_SYS_POLL_H
90b7d6d
- #   include <sys/poll.h>
90b7d6d
- #  else
90b7d6d
- #   ifdef HAVE_POLL_H
90b7d6d
- #    include <poll.h>
90b7d6d
- #   endif
90b7d6d
- #  endif
90b7d6d
- # endif
90b7d6d
- 
90b7d6d
  /*
90b7d6d
   * This file provides procedures that implement the command server
90b7d6d
   * functionality of Vim when in contact with an X11 server.
90b7d6d
--- 21,26 ----
90b7d6d
*** ../vim-7.2.391/src/netbeans.c	2010-01-19 15:12:33.000000000 +0100
90b7d6d
--- src/netbeans.c	2010-03-10 15:21:37.000000000 +0100
90b7d6d
***************
90b7d6d
*** 736,741 ****
90b7d6d
--- 736,749 ----
90b7d6d
  #ifndef FEAT_GUI_GTK
90b7d6d
      static int		level = 0;
90b7d6d
  #endif
90b7d6d
+ #ifdef HAVE_SELECT
90b7d6d
+     struct timeval	tval;
90b7d6d
+     fd_set		rfds;
90b7d6d
+ #else
90b7d6d
+ # ifdef HAVE_POLL
90b7d6d
+     struct pollfd	fds;
90b7d6d
+ # endif
90b7d6d
+ #endif
90b7d6d
  
90b7d6d
      if (sd < 0)
90b7d6d
      {
90b7d6d
***************
90b7d6d
*** 755,763 ****
90b7d6d
  	    return;	/* out of memory! */
90b7d6d
      }
90b7d6d
  
90b7d6d
!     /* Keep on reading for as long as there is something to read. */
90b7d6d
      for (;;)
90b7d6d
      {
90b7d6d
  	len = sock_read(sd, buf, MAXMSGSIZE);
90b7d6d
  	if (len <= 0)
90b7d6d
  	    break;	/* error or nothing more to read */
90b7d6d
--- 763,788 ----
90b7d6d
  	    return;	/* out of memory! */
90b7d6d
      }
90b7d6d
  
90b7d6d
!     /* Keep on reading for as long as there is something to read.
90b7d6d
!      * Use select() or poll() to avoid blocking on a message that is exactly
90b7d6d
!      * MAXMSGSIZE long. */
90b7d6d
      for (;;)
90b7d6d
      {
90b7d6d
+ #ifdef HAVE_SELECT
90b7d6d
+ 	FD_ZERO(&rfds);
90b7d6d
+         FD_SET(sd, &rfds);
90b7d6d
+         tval.tv_sec = 0;
90b7d6d
+         tval.tv_usec = 0;
90b7d6d
+         if (select(sd + 1, &rfds, NULL, NULL, &tval) <= 0)
90b7d6d
+             break;
90b7d6d
+ #else
90b7d6d
+ # ifdef HAVE_POLL
90b7d6d
+ 	fds.fd = sd;
90b7d6d
+ 	fds.events = POLLIN;
90b7d6d
+         if (poll(&fds, 1, 0) <= 0)
90b7d6d
+             break;
90b7d6d
+ # endif
90b7d6d
+ #endif
90b7d6d
  	len = sock_read(sd, buf, MAXMSGSIZE);
90b7d6d
  	if (len <= 0)
90b7d6d
  	    break;	/* error or nothing more to read */
90b7d6d
*** ../vim-7.2.391/src/version.c	2010-03-10 14:46:21.000000000 +0100
90b7d6d
--- src/version.c	2010-03-10 16:10:48.000000000 +0100
90b7d6d
***************
90b7d6d
*** 683,684 ****
90b7d6d
--- 683,686 ----
90b7d6d
  {   /* Add new patch number below this line */
90b7d6d
+ /**/
90b7d6d
+     392,
90b7d6d
  /**/
90b7d6d
90b7d6d
-- 
90b7d6d
WOMAN:   I didn't know we had a king. I thought we were an autonomous
90b7d6d
         collective.
90b7d6d
DENNIS:  You're fooling yourself.  We're living in a dictatorship.  A
90b7d6d
         self-perpetuating autocracy in which the working classes--
90b7d6d
WOMAN:   Oh there you go, bringing class into it again.
90b7d6d
DENNIS:  That's what it's all about if only people would--
90b7d6d
                                  The Quest for the Holy Grail (Monty Python)
90b7d6d
90b7d6d
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
90b7d6d
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
90b7d6d
\\\        download, build and distribute -- http://www.A-A-P.org        ///
90b7d6d
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///