Karsten Hopp ffb015
To: vim_dev@googlegroups.com
Karsten Hopp ffb015
Subject: Patch 7.3.595
Karsten Hopp ffb015
Fcc: outbox
Karsten Hopp ffb015
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp ffb015
Mime-Version: 1.0
Karsten Hopp ffb015
Content-Type: text/plain; charset=UTF-8
Karsten Hopp ffb015
Content-Transfer-Encoding: 8bit
Karsten Hopp ffb015
------------
Karsten Hopp ffb015
Karsten Hopp ffb015
Patch 7.3.595
Karsten Hopp ffb015
Problem:    The X command server responds slowly
Karsten Hopp ffb015
Solution:   Change the loop that waits for replies. (Brian Burns)
Karsten Hopp ffb015
Files:	    src/if_xcmdsrv.c
Karsten Hopp ffb015
Karsten Hopp ffb015
Karsten Hopp ffb015
*** ../vim-7.3.594/src/if_xcmdsrv.c	2012-07-10 14:25:00.000000000 +0200
Karsten Hopp ffb015
--- src/if_xcmdsrv.c	2012-07-10 14:44:13.000000000 +0200
Karsten Hopp ffb015
***************
Karsten Hopp ffb015
*** 572,632 ****
Karsten Hopp ffb015
  {
Karsten Hopp ffb015
      time_t	    start;
Karsten Hopp ffb015
      time_t	    now;
Karsten Hopp ffb015
-     time_t	    lastChk = 0;
Karsten Hopp ffb015
      XEvent	    event;
Karsten Hopp ffb015
!     XPropertyEvent *e = (XPropertyEvent *)&event;
Karsten Hopp ffb015
! #   define SEND_MSEC_POLL 50
Karsten Hopp ffb015
  
Karsten Hopp ffb015
      time(&start;;
Karsten Hopp ffb015
!     while (endCond(endData) == 0)
Karsten Hopp ffb015
      {
Karsten Hopp ffb015
  	time(&now;;
Karsten Hopp ffb015
  	if (seconds >= 0 && (now - start) >= seconds)
Karsten Hopp ffb015
  	    break;
Karsten Hopp ffb015
! 	if (now != lastChk)
Karsten Hopp ffb015
! 	{
Karsten Hopp ffb015
! 	    lastChk = now;
Karsten Hopp ffb015
! 	    if (!WindowValid(dpy, w))
Karsten Hopp ffb015
! 		break;
Karsten Hopp ffb015
! 	    /*
Karsten Hopp ffb015
! 	     * Sometimes the PropertyChange event doesn't come.
Karsten Hopp ffb015
! 	     * This can be seen in eg: vim -c 'echo remote_expr("gvim", "3+2")'
Karsten Hopp ffb015
! 	     */
Karsten Hopp ffb015
! 	    serverEventProc(dpy, NULL);
Karsten Hopp ffb015
! 	}
Karsten Hopp ffb015
  	if (localLoop)
Karsten Hopp ffb015
  	{
Karsten Hopp ffb015
- 	    /* Just look out for the answer without calling back into Vim */
Karsten Hopp ffb015
  #ifndef HAVE_SELECT
Karsten Hopp ffb015
- 	    struct pollfd   fds;
Karsten Hopp ffb015
- 
Karsten Hopp ffb015
- 	    fds.fd = ConnectionNumber(dpy);
Karsten Hopp ffb015
- 	    fds.events = POLLIN;
Karsten Hopp ffb015
  	    if (poll(&fds, 1, SEND_MSEC_POLL) < 0)
Karsten Hopp ffb015
  		break;
Karsten Hopp ffb015
  #else
Karsten Hopp ffb015
! 	    fd_set	    fds;
Karsten Hopp ffb015
! 	    struct timeval  tv;
Karsten Hopp ffb015
! 
Karsten Hopp ffb015
! 	    tv.tv_sec = 0;
Karsten Hopp ffb015
! 	    tv.tv_usec =  SEND_MSEC_POLL * 1000;
Karsten Hopp ffb015
! 	    FD_ZERO(&fds);
Karsten Hopp ffb015
! 	    FD_SET(ConnectionNumber(dpy), &fds);
Karsten Hopp ffb015
! 	    if (select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &tv) < 0)
Karsten Hopp ffb015
  		break;
Karsten Hopp ffb015
  #endif
Karsten Hopp ffb015
- 	    while (XEventsQueued(dpy, QueuedAfterReading) > 0)
Karsten Hopp ffb015
- 	    {
Karsten Hopp ffb015
- 		XNextEvent(dpy, &event);
Karsten Hopp ffb015
- 		if (event.type == PropertyNotify && e->window == commWindow)
Karsten Hopp ffb015
- 		    serverEventProc(dpy, &event);
Karsten Hopp ffb015
- 	    }
Karsten Hopp ffb015
  	}
Karsten Hopp ffb015
  	else
Karsten Hopp ffb015
  	{
Karsten Hopp ffb015
  	    if (got_int)
Karsten Hopp ffb015
  		break;
Karsten Hopp ffb015
! 	    ui_delay((long)SEND_MSEC_POLL, TRUE);
Karsten Hopp ffb015
  	    ui_breakcheck();
Karsten Hopp ffb015
  	}
Karsten Hopp ffb015
      }
Karsten Hopp ffb015
--- 572,626 ----
Karsten Hopp ffb015
  {
Karsten Hopp ffb015
      time_t	    start;
Karsten Hopp ffb015
      time_t	    now;
Karsten Hopp ffb015
      XEvent	    event;
Karsten Hopp ffb015
! 
Karsten Hopp ffb015
! #define UI_MSEC_DELAY 50
Karsten Hopp ffb015
! #define SEND_MSEC_POLL 500
Karsten Hopp ffb015
! #ifndef HAVE_SELECT
Karsten Hopp ffb015
!     struct pollfd   fds;
Karsten Hopp ffb015
! 
Karsten Hopp ffb015
!     fds.fd = ConnectionNumber(dpy);
Karsten Hopp ffb015
!     fds.events = POLLIN;
Karsten Hopp ffb015
! #else
Karsten Hopp ffb015
!     fd_set	    fds;
Karsten Hopp ffb015
!     struct timeval  tv;
Karsten Hopp ffb015
! 
Karsten Hopp ffb015
!     tv.tv_sec = 0;
Karsten Hopp ffb015
!     tv.tv_usec =  SEND_MSEC_POLL * 1000;
Karsten Hopp ffb015
!     FD_ZERO(&fds);
Karsten Hopp ffb015
!     FD_SET(ConnectionNumber(dpy), &fds);
Karsten Hopp ffb015
! #endif
Karsten Hopp ffb015
  
Karsten Hopp ffb015
      time(&start;;
Karsten Hopp ffb015
!     while (TRUE)
Karsten Hopp ffb015
      {
Karsten Hopp ffb015
+ 	while (XCheckWindowEvent(dpy, commWindow, PropertyChangeMask, &event))
Karsten Hopp ffb015
+ 	    serverEventProc(dpy, &event);
Karsten Hopp ffb015
+ 
Karsten Hopp ffb015
+ 	if (endCond(endData) != 0)
Karsten Hopp ffb015
+ 	    break;
Karsten Hopp ffb015
+ 	if (!WindowValid(dpy, w))
Karsten Hopp ffb015
+ 	    break;
Karsten Hopp ffb015
  	time(&now;;
Karsten Hopp ffb015
  	if (seconds >= 0 && (now - start) >= seconds)
Karsten Hopp ffb015
  	    break;
Karsten Hopp ffb015
! 
Karsten Hopp ffb015
! 	/* Just look out for the answer without calling back into Vim */
Karsten Hopp ffb015
  	if (localLoop)
Karsten Hopp ffb015
  	{
Karsten Hopp ffb015
  #ifndef HAVE_SELECT
Karsten Hopp ffb015
  	    if (poll(&fds, 1, SEND_MSEC_POLL) < 0)
Karsten Hopp ffb015
  		break;
Karsten Hopp ffb015
  #else
Karsten Hopp ffb015
! 	    if (select(FD_SETSIZE, &fds, NULL, NULL, &tv) < 0)
Karsten Hopp ffb015
  		break;
Karsten Hopp ffb015
  #endif
Karsten Hopp ffb015
  	}
Karsten Hopp ffb015
  	else
Karsten Hopp ffb015
  	{
Karsten Hopp ffb015
  	    if (got_int)
Karsten Hopp ffb015
  		break;
Karsten Hopp ffb015
! 	    ui_delay((long)UI_MSEC_DELAY, TRUE);
Karsten Hopp ffb015
  	    ui_breakcheck();
Karsten Hopp ffb015
  	}
Karsten Hopp ffb015
      }
Karsten Hopp ffb015
*** ../vim-7.3.594/src/version.c	2012-07-10 14:25:00.000000000 +0200
Karsten Hopp ffb015
--- src/version.c	2012-07-10 14:52:16.000000000 +0200
Karsten Hopp ffb015
***************
Karsten Hopp ffb015
*** 716,717 ****
Karsten Hopp ffb015
--- 716,719 ----
Karsten Hopp ffb015
  {   /* Add new patch number below this line */
Karsten Hopp ffb015
+ /**/
Karsten Hopp ffb015
+     595,
Karsten Hopp ffb015
  /**/
Karsten Hopp ffb015
Karsten Hopp ffb015
-- 
Karsten Hopp ffb015
hundred-and-one symptoms of being an internet addict:
Karsten Hopp ffb015
104. When people ask about the Presidential Election you ask "Which country?"
Karsten Hopp ffb015
Karsten Hopp ffb015
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp ffb015
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp ffb015
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp ffb015
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///