Patch 7.4.1887
Problem:    When receiving channel data 'updatetime' is not respected.
Solution:   Recompute the waiting time after being interrupted.
Files:      src/os_unix.c


*** ../vim-7.4.1886/src/os_unix.c       2016-06-04 13:32:31.042331459 +0200
--- src/os_unix.c       2016-06-04 13:58:39.474309884 +0200
***************
*** 369,374 ****
--- 369,389 ----
        RealWaitForChar(read_cmd_fd, p_wd, NULL, NULL);
  }
  
+ #if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
+ /*
+  * Return time in msec since "start_tv".
+  */
+     static long
+ elapsed(struct timeval *start_tv)
+ {
+     struct timeval  now_tv;
+ 
+     gettimeofday(&now_tv, NULL);
+     return (now_tv.tv_sec - start_tv->tv_sec) * 1000L
+        + (now_tv.tv_usec - start_tv->tv_usec) / 1000L;
+ }
+ #endif
+ 
  /*
   * mch_inchar(): low level input function.
   * Get a characters from the keyboard.
***************
*** 386,391 ****
--- 401,412 ----
  {
      int               len;
      int               interrupted = FALSE;
+     long      wait_time;
+ #if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
+     struct timeval  start_tv;
+ 
+     gettimeofday(&start_tv, NULL);
+ #endif
  
  #ifdef MESSAGE_QUEUE
      parse_queued_messages();
***************
*** 396,406 ****
      while (do_resize)
        handle_resize();
  
!     if (wtime >= 0)
      {
!       /* TODO: when looping reduce wtime by the elapsed time. */
!       while (!WaitForChar(wtime, &interrupted))
        {
            /* no character available */
            if (do_resize)
            {
--- 417,436 ----
      while (do_resize)
        handle_resize();
  
!     for (;;)
      {
!       if (wtime >= 0)
!           wait_time = wtime;
!       else
!           wait_time = p_ut;
! #if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
!       wait_time -= elapsed(&start_tv);
!       if (wait_time >= 0)
        {
+ #endif
+           if (WaitForChar(wait_time, &interrupted))
+               break;
+ 
            /* no character available */
            if (do_resize)
            {
***************
*** 421,452 ****
                continue;
            }
  #endif
!           /* return if not interrupted by resize or server */
            return 0;
        }
!     }
!     else      /* wtime == -1 */
!     {
        /*
         * If there is no character available within 'updatetime' seconds
         * flush all the swap files to disk.
         * Also done when interrupted by SIGWINCH.
         */
!       if (!WaitForChar(p_ut, &interrupted))
!       {
!           /* TODO: if interrupted is set loop to wait the remaining time. */
! #ifdef FEAT_AUTOCMD
!           if (trigger_cursorhold() && maxlen >= 3
!                                          && !typebuf_changed(tb_change_cnt))
!           {
!               buf[0] = K_SPECIAL;
!               buf[1] = KS_EXTRA;
!               buf[2] = (int)KE_CURSORHOLD;
!               return 3;
!           }
! #endif
!           before_blocking();
!       }
      }
  
      /* repeat until we got a character */
--- 451,481 ----
                continue;
            }
  #endif
! #if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
!       }
! #endif
!       if (wtime >= 0)
!           /* no character available within "wtime" */
            return 0;
+ 
+       /* wtime == -1: no character available within 'updatetime' */
+ #ifdef FEAT_AUTOCMD
+       if (trigger_cursorhold() && maxlen >= 3
+                                          && !typebuf_changed(tb_change_cnt))
+       {
+           buf[0] = K_SPECIAL;
+           buf[1] = KS_EXTRA;
+           buf[2] = (int)KE_CURSORHOLD;
+           return 3;
        }
! #endif
        /*
         * If there is no character available within 'updatetime' seconds
         * flush all the swap files to disk.
         * Also done when interrupted by SIGWINCH.
         */
!       before_blocking();
!       break;
      }
  
      /* repeat until we got a character */
***************
*** 1512,1533 ****
  # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) \
        && (defined(FEAT_XCLIPBOARD) || defined(FEAT_TITLE))
  
! static void xopen_message(struct timeval *tvp);
  
  /*
   * Give a message about the elapsed time for opening the X window.
   */
      static void
! xopen_message(
!     struct timeval *tvp)      /* must contain start time */
  {
!     struct timeval  end_tv;
! 
!     /* Compute elapsed time. */
!     gettimeofday(&end_tv, NULL);
!     smsg((char_u *)_("Opening the X display took %ld msec"),
!           (end_tv.tv_sec - tvp->tv_sec) * 1000L
!                                  + (end_tv.tv_usec - tvp->tv_usec) / 1000L);
  }
  # endif
  #endif
--- 1541,1555 ----
  # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) \
        && (defined(FEAT_XCLIPBOARD) || defined(FEAT_TITLE))
  
! static void xopen_message(struct timeval *start_tv);
  
  /*
   * Give a message about the elapsed time for opening the X window.
   */
      static void
! xopen_message(struct timeval *start_tv)
  {
!     smsg((char_u *)_("Opening the X display took %ld msec"), 
elapsed(start_tv));
  }
  # endif
  #endif
***************
*** 4880,4894 ****
  # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
                        if (wait_pid == 0)
                        {
!                           struct timeval  now_tv;
!                           long            msec;
  
                            /* Avoid that we keep looping here without
                             * checking for a CTRL-C for a long time.  Don't
                             * break out too often to avoid losing typeahead. */
-                           gettimeofday(&now_tv, NULL);
-                           msec = (now_tv.tv_sec - start_tv.tv_sec) * 1000L
-                                + (now_tv.tv_usec - start_tv.tv_usec) / 1000L;
                            if (msec > 2000)
                            {
                                noread_cnt = 5;
--- 4902,4912 ----
  # if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
                        if (wait_pid == 0)
                        {
!                           long            msec = elapsed(&start_tv);
  
                            /* Avoid that we keep looping here without
                             * checking for a CTRL-C for a long time.  Don't
                             * break out too often to avoid losing typeahead. */
                            if (msec > 2000)
                            {
                                noread_cnt = 5;
***************
*** 5892,5903 ****
        if (msec > 0)
        {
  # ifdef USE_START_TV
-           struct timeval  mtv;
- 
            /* Compute remaining wait time. */
!           gettimeofday(&mtv, NULL);
!           msec -= (mtv.tv_sec - start_tv.tv_sec) * 1000L
!                                  + (mtv.tv_usec - start_tv.tv_usec) / 1000L;
  # else
            /* Guess we got interrupted halfway. */
            msec = msec / 2;
--- 5910,5917 ----
        if (msec > 0)
        {
  # ifdef USE_START_TV
            /* Compute remaining wait time. */
!           msec -= elapsed(&start_tv);
  # else
            /* Guess we got interrupted halfway. */
            msec = msec / 2;
*** ../vim-7.4.1886/src/version.c       2016-06-04 13:32:31.042331459 +0200
--- src/version.c       2016-06-04 13:59:36.694309097 +0200
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     1887,
  /**/

-- 
Well, you come from nothing, you go back to nothing...  What have you
lost?  Nothing!
                                -- Monty Python: The life of Brian

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui