Patch 7.4.1826
Problem:    Callbacks are invoked when it's not safe. (Andrew Stewart)
Solution:   When a channel is to be closed don't invoke callbacks right away,
            wait for a safe moment.
Files:      src/structs.h, src/channel.c


*** ../vim-7.4.1825/src/structs.h       2016-04-29 22:58:25.622876633 +0200
--- src/structs.h       2016-05-09 17:07:32.120714293 +0200
***************
*** 1416,1421 ****
--- 1416,1424 ----
      char      *ch_hostname;   /* only for socket, allocated */
      int               ch_port;        /* only for socket */
  
+     int               ch_to_be_closed; /* When TRUE reading or writing failed 
and
+                                 * the channel must be closed when it's safe
+                                 * to invoke callbacks. */
      int               ch_error;       /* When TRUE an error was reported.  
Avoids
                                 * giving pages full of error messages when
                                 * the other side has exited, only mention the
*** ../vim-7.4.1825/src/channel.c       2016-05-08 21:46:56.168690797 +0200
--- src/channel.c       2016-05-09 17:13:27.844763619 +0200
***************
*** 2782,2788 ****
  channel_close_on_error(channel_T *channel, char *func)
  {
      /* Do not call emsg(), most likely the other end just exited. */
!     ch_errors(channel, "%s(): Cannot read from channel", func);
  
      /* Queue a "DETACH" netbeans message in the command queue in order to
       * terminate the netbeans session later. Do not end the session here
--- 2782,2789 ----
  channel_close_on_error(channel_T *channel, char *func)
  {
      /* Do not call emsg(), most likely the other end just exited. */
!     ch_errors(channel, "%s(): Cannot read from channel, will close it soon",
!                                                                       func);
  
      /* Queue a "DETACH" netbeans message in the command queue in order to
       * terminate the netbeans session later. Do not end the session here
***************
*** 2800,2806 ****
                              (int)STRLEN(DETACH_MSG_RAW), FALSE, "PUT ");
  
      /* When reading from stdout is not possible, assume the other side has
!      * died. */
      channel_close(channel, TRUE);
      if (channel->ch_nb_close_cb != NULL)
        (*channel->ch_nb_close_cb)();
--- 2801,2815 ----
                              (int)STRLEN(DETACH_MSG_RAW), FALSE, "PUT ");
  
      /* When reading from stdout is not possible, assume the other side has
!      * died.  Don't close the channel right away, it may be the wrong moment
!      * to invoke callbacks. */
!     channel->ch_to_be_closed = TRUE;
! }
! 
!     static void
! channel_close_now(channel_T *channel)
! {
!     ch_log(channel, "Closing channel because of previous read error");
      channel_close(channel, TRUE);
      if (channel->ch_nb_close_cb != NULL)
        (*channel->ch_nb_close_cb)();
***************
*** 3515,3520 ****
--- 3524,3537 ----
      }
      while (channel != NULL)
      {
+       if (channel->ch_to_be_closed)
+       {
+           channel->ch_to_be_closed = FALSE;
+           channel_close_now(channel);
+           /* channel may have been freed, start over */
+           channel = first_channel;
+           continue;
+       }
        if (channel->ch_refcount == 0 && !channel_still_useful(channel))
        {
            /* channel is no longer useful, free it */
*** ../vim-7.4.1825/src/version.c       2016-05-08 21:46:56.172690753 +0200
--- src/version.c       2016-05-09 17:08:44.071915308 +0200
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     1826,
  /**/

-- 
ARTHUR: It is I, Arthur, son of Uther Pendragon, from the castle of Camelot.
        King of all Britons, defeator of the Saxons, sovereign of all England!
   [Pause]
SOLDIER: Get away!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

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