Patch 7.4.1657
Problem:    On Unix in a terminal: channel messages are not handled right away.
            (Jackson Alves de Aquino)
Solution:   Break the loop for timers when something was received.
Files:      src/os_unix.c


*** ../vim-7.4.1656/src/os_unix.c       2016-03-20 21:01:55.237112377 +0100
--- src/os_unix.c       2016-03-26 19:26:03.012776748 +0100
***************
*** 176,186 ****
  static pid_t wait4pid(pid_t, waitstatus *);
  
  static int  WaitForChar(long);
! static int  WaitForCharOrMouse(long);
  #if defined(__BEOS__) || defined(VMS)
! int  RealWaitForChar(int, long, int *);
  #else
! static int  RealWaitForChar(int, long, int *);
  #endif
  
  #ifdef FEAT_XCLIPBOARD
--- 176,186 ----
  static pid_t wait4pid(pid_t, waitstatus *);
  
  static int  WaitForChar(long);
! static int  WaitForCharOrMouse(long, int *break_loop);
  #if defined(__BEOS__) || defined(VMS)
! int  RealWaitForChar(int, long, int *, int *break_loop);
  #else
! static int  RealWaitForChar(int, long, int *, int *break_loop);
  #endif
  
  #ifdef FEAT_XCLIPBOARD
***************
*** 366,372 ****
  {
      ignored = (int)write(1, (char *)s, len);
      if (p_wd)         /* Unix is too fast, slow down a bit more */
!       RealWaitForChar(read_cmd_fd, p_wd, NULL);
  }
  
  /*
--- 366,372 ----
  {
      ignored = (int)write(1, (char *)s, len);
      if (p_wd)         /* Unix is too fast, slow down a bit more */
!       RealWaitForChar(read_cmd_fd, p_wd, NULL, NULL);
  }
  
  /*
***************
*** 4762,4768 ****
                     * to some terminal (vt52?).
                     */
                    ++noread_cnt;
!                   while (RealWaitForChar(fromshell_fd, 10L, NULL))
                    {
                        len = read_eintr(fromshell_fd, buffer
  # ifdef FEAT_MBYTE
--- 4762,4768 ----
                     * to some terminal (vt52?).
                     */
                    ++noread_cnt;
!                   while (RealWaitForChar(fromshell_fd, 10L, NULL, NULL))
                    {
                        len = read_eintr(fromshell_fd, buffer
  # ifdef FEAT_MBYTE
***************
*** 5343,5349 ****
      void
  mch_breakcheck(void)
  {
!     if (curr_tmode == TMODE_RAW && RealWaitForChar(read_cmd_fd, 0L, NULL))
        fill_input_buf(FALSE);
  }
  
--- 5343,5349 ----
      void
  mch_breakcheck(void)
  {
!     if (curr_tmode == TMODE_RAW && RealWaitForChar(read_cmd_fd, 0L, NULL, 
NULL))
        fill_input_buf(FALSE);
  }
  
***************
*** 5360,5369 ****
  #ifdef FEAT_TIMERS
      long    due_time;
      long    remaining = msec;
  
      /* When waiting very briefly don't trigger timers. */
      if (msec >= 0 && msec < 10L)
!       return WaitForCharOrMouse(msec);
  
      while (msec < 0 || remaining > 0)
      {
--- 5360,5370 ----
  #ifdef FEAT_TIMERS
      long    due_time;
      long    remaining = msec;
+     int           break_loop = FALSE;
  
      /* When waiting very briefly don't trigger timers. */
      if (msec >= 0 && msec < 10L)
!       return WaitForCharOrMouse(msec, NULL);
  
      while (msec < 0 || remaining > 0)
      {
***************
*** 5372,5385 ****
        due_time = check_due_timer();
        if (due_time <= 0 || (msec > 0 && due_time > remaining))
            due_time = remaining;
!       if (WaitForCharOrMouse(due_time))
            return TRUE;
        if (msec > 0)
            remaining -= due_time;
      }
      return FALSE;
  #else
!     return WaitForCharOrMouse(msec);
  #endif
  }
  
--- 5373,5390 ----
        due_time = check_due_timer();
        if (due_time <= 0 || (msec > 0 && due_time > remaining))
            due_time = remaining;
!       if (WaitForCharOrMouse(due_time, &break_loop))
            return TRUE;
+       if (break_loop)
+           /* Nothing available, but need to return so that side effects get
+            * handled, such as handling a message on a channel. */
+           return FALSE;
        if (msec > 0)
            remaining -= due_time;
      }
      return FALSE;
  #else
!     return WaitForCharOrMouse(msec, NULL);
  #endif
  }
  
***************
*** 5390,5396 ****
   * When a GUI is being used, this will never get called -- webb
   */
      static int
! WaitForCharOrMouse(long msec)
  {
  #ifdef FEAT_MOUSE_GPM
      int               gpm_process_wanted;
--- 5395,5401 ----
   * When a GUI is being used, this will never get called -- webb
   */
      static int
! WaitForCharOrMouse(long msec, int *break_loop)
  {
  #ifdef FEAT_MOUSE_GPM
      int               gpm_process_wanted;
***************
*** 5436,5444 ****
  # endif
  # ifdef FEAT_MOUSE_GPM
        gpm_process_wanted = 0;
!       avail = RealWaitForChar(read_cmd_fd, msec, &gpm_process_wanted);
  # else
!       avail = RealWaitForChar(read_cmd_fd, msec, NULL);
  # endif
        if (!avail)
        {
--- 5441,5450 ----
  # endif
  # ifdef FEAT_MOUSE_GPM
        gpm_process_wanted = 0;
!       avail = RealWaitForChar(read_cmd_fd, msec,
!                                            &gpm_process_wanted, break_loop);
  # else
!       avail = RealWaitForChar(read_cmd_fd, msec, NULL, break_loop);
  # endif
        if (!avail)
        {
***************
*** 5457,5466 ****
  # ifdef FEAT_XCLIPBOARD
           || (!avail && rest != 0)
  # endif
!         );
  
  #else
!     avail = RealWaitForChar(read_cmd_fd, msec, NULL);
  #endif
      return avail;
  }
--- 5463,5473 ----
  # ifdef FEAT_XCLIPBOARD
           || (!avail && rest != 0)
  # endif
!         )
!       ;
  
  #else
!     avail = RealWaitForChar(read_cmd_fd, msec, NULL, &break_loop);
  #endif
      return avail;
  }
***************
*** 5479,5485 ****
  #else
      static int
  #endif
! RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED)
  {
      int               ret;
      int               result;
--- 5486,5492 ----
  #else
      static int
  #endif
! RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *break_loop)
  {
      int               ret;
      int               result;
***************
*** 5592,5597 ****
--- 5599,5606 ----
        ret = poll(fds, nfd, towait);
  
        result = ret > 0 && (fds[0].revents & POLLIN);
+       if (break_loop != NULL && ret > 0)
+           *break_loop = TRUE;
  
  # ifdef FEAT_MZSCHEME
        if (ret == 0 && mzquantum_used)
***************
*** 5723,5728 ****
--- 5732,5739 ----
        result = ret > 0 && FD_ISSET(fd, &rfds);
        if (result)
            --ret;
+       if (break_loop != NULL && ret > 0)
+           *break_loop = TRUE;
  
  # ifdef EINTR
        if (ret == -1 && errno == EINTR)
*** ../vim-7.4.1656/src/version.c       2016-03-26 18:20:36.953052900 +0100
--- src/version.c       2016-03-26 19:28:03.243539933 +0100
***************
*** 750,751 ****
--- 750,753 ----
  {   /* Add new patch number below this line */
+ /**/
+     1657,
  /**/

-- 
Why is it called "Windows"?  "Gates" would be more appropriate...

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