comparison src/channel.c @ 9050:31bba6f25d84 v7.4.1810

commit https://github.com/vim/vim/commit/715d285d79a1d97928dd717278e25e6de45d1496 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 30 17:06:31 2016 +0200 patch 7.4.1810 Problem: Sending DETACH after a channel was closed isn't useful. Solution: Only add DETACH for a netbeans channel.
author Christian Brabandt <cb@256bit.org>
date Sat, 30 Apr 2016 17:15:04 +0200
parents 5abf6f38cbbb
children 87c2e43a4a12
comparison
equal deleted inserted replaced
9049:3ccfa1e31cad 9050:31bba6f25d84
2593 channel_clear(channel); 2593 channel_clear(channel);
2594 } 2594 }
2595 #endif 2595 #endif
2596 2596
2597 2597
2598 /* Sent when the channel is found closed when reading. */ 2598 /* Sent when the netbeans channel is found closed when reading. */
2599 #define DETACH_MSG_RAW "DETACH\n" 2599 #define DETACH_MSG_RAW "DETACH\n"
2600 2600
2601 /* Buffer size for reading incoming messages. */ 2601 /* Buffer size for reading incoming messages. */
2602 #define MAXMSGSIZE 4096 2602 #define MAXMSGSIZE 4096
2603 2603
2764 } 2764 }
2765 return CW_NOT_READY; 2765 return CW_NOT_READY;
2766 } 2766 }
2767 2767
2768 static void 2768 static void
2769 channel_close_on_error(channel_T *channel, int part, char *func) 2769 channel_close_on_error(channel_T *channel, char *func)
2770 { 2770 {
2771 /* Do not call emsg(), most likely the other end just exited. */ 2771 /* Do not call emsg(), most likely the other end just exited. */
2772 ch_errors(channel, "%s(): Cannot read from channel", func); 2772 ch_errors(channel, "%s(): Cannot read from channel", func);
2773 2773
2774 /* Queue a "DETACH" netbeans message in the command queue in order to 2774 /* Queue a "DETACH" netbeans message in the command queue in order to
2778 * netbeans_parse_messages 2778 * netbeans_parse_messages
2779 * -> autocmd triggered while processing the netbeans cmd 2779 * -> autocmd triggered while processing the netbeans cmd
2780 * -> ui_breakcheck 2780 * -> ui_breakcheck
2781 * -> gui event loop or select loop 2781 * -> gui event loop or select loop
2782 * -> channel_read() 2782 * -> channel_read()
2783 * Don't send "DETACH" for a JS or JSON channel. 2783 * Only send "DETACH" for a netbeans channel.
2784 */ 2784 */
2785 if (channel->ch_part[part].ch_mode == MODE_RAW 2785 if (channel->ch_nb_close_cb != NULL)
2786 || channel->ch_part[part].ch_mode == MODE_NL)
2787 channel_save(channel, PART_OUT, (char_u *)DETACH_MSG_RAW, 2786 channel_save(channel, PART_OUT, (char_u *)DETACH_MSG_RAW,
2788 (int)STRLEN(DETACH_MSG_RAW), FALSE, "PUT "); 2787 (int)STRLEN(DETACH_MSG_RAW), FALSE, "PUT ");
2789 2788
2790 /* When reading from stdout is not possible, assume the other side has 2789 /* When reading from stdout is not possible, assume the other side has
2791 * died. */ 2790 * died. */
2845 break; /* did read everything that's available */ 2844 break; /* did read everything that's available */
2846 } 2845 }
2847 2846
2848 /* Reading a disconnection (readlen == 0), or an error. */ 2847 /* Reading a disconnection (readlen == 0), or an error. */
2849 if (readlen <= 0) 2848 if (readlen <= 0)
2850 channel_close_on_error(channel, part, func); 2849 channel_close_on_error(channel, func);
2851 2850
2852 #if defined(CH_HAS_GUI) && defined(FEAT_GUI_GTK) 2851 #if defined(CH_HAS_GUI) && defined(FEAT_GUI_GTK)
2853 /* signal the main loop that there is something to read */ 2852 /* signal the main loop that there is something to read */
2854 if (CH_HAS_GUI && gtk_main_level() > 0) 2853 if (CH_HAS_GUI && gtk_main_level() > 0)
2855 gtk_main_quit(); 2854 gtk_main_quit();
3117 int r = channel_wait(channel, fd, 0); 3116 int r = channel_wait(channel, fd, 0);
3118 3117
3119 if (r == CW_READY) 3118 if (r == CW_READY)
3120 channel_read(channel, part, "channel_handle_events"); 3119 channel_read(channel, part, "channel_handle_events");
3121 else if (r == CW_ERROR) 3120 else if (r == CW_ERROR)
3122 channel_close_on_error(channel, part, 3121 channel_close_on_error(channel, "channel_handle_events()");
3123 "channel_handle_events()");
3124 } 3122 }
3125 } 3123 }
3126 } 3124 }
3127 } 3125 }
3128 # endif 3126 # endif