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