0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 7.4.1319

Problem:    Tests fail on MS-Windows and on Unix with GUI.
Solution:   Fix unregistering.
This commit is contained in:
Bram Moolenaar 2016-02-14 23:02:34 +01:00
parent 7b3ca76a45
commit 16eb4f8800
6 changed files with 81 additions and 73 deletions

View File

@ -339,7 +339,8 @@ channel_gui_register_one(channel_T *channel, int which)
* is input on the editor connection socket. */ * is input on the editor connection socket. */
if (channel->ch_pfd[which].ch_inputHandler == 0) if (channel->ch_pfd[which].ch_inputHandler == 0)
channel->ch_pfd[which].ch_inputHandler = gdk_input_add( channel->ch_pfd[which].ch_inputHandler = gdk_input_add(
(gint)channel->ch_pfd[which].ch_fd, (GdkInputCondition) (gint)channel->ch_pfd[which].ch_fd,
(GdkInputCondition)
((int)GDK_INPUT_READ + (int)GDK_INPUT_EXCEPTION), ((int)GDK_INPUT_READ + (int)GDK_INPUT_EXCEPTION),
messageFromNetbeans, messageFromNetbeans,
(gpointer)(long)channel->ch_id); (gpointer)(long)channel->ch_id);
@ -362,12 +363,12 @@ channel_gui_register(channel_T *channel)
if (!CH_HAS_GUI) if (!CH_HAS_GUI)
return; return;
if (channel->ch_pfd[CHAN_SOCK].ch_fd >= 0) if (channel->CH_SOCK >= 0)
channel_gui_register_one(channel, CHAN_SOCK); channel_gui_register_one(channel, CHAN_SOCK);
# ifdef CHANNEL_PIPES # ifdef CHANNEL_PIPES
if (channel->ch_pfd[CHAN_OUT].ch_fd >= 0) if (channel->CH_OUT >= 0)
channel_gui_register_one(channel, CHAN_OUT); channel_gui_register_one(channel, CHAN_OUT);
if (channel->ch_pfd[CHAN_ERR].ch_fd >= 0) if (channel->CH_ERR >= 0)
channel_gui_register_one(channel, CHAN_ERR); channel_gui_register_one(channel, CHAN_ERR);
# endif # endif
} }
@ -386,7 +387,15 @@ channel_gui_register_all(void)
} }
static void static void
channel_gui_unregister_one(channel_T *channel, int which) channel_gui_unregister(channel_T *channel)
{
int which;
#ifdef CHANNEL_PIPES
for (which = CHAN_SOCK; which < CHAN_IN; ++which)
#else
which = CHAN_SOCK;
#endif
{ {
# ifdef FEAT_GUI_X11 # ifdef FEAT_GUI_X11
if (channel->ch_pfd[which].ch_inputHandler != (XtInputId)NULL) if (channel->ch_pfd[which].ch_inputHandler != (XtInputId)NULL)
@ -412,18 +421,6 @@ channel_gui_unregister_one(channel_T *channel, int which)
# endif # endif
# endif # endif
} }
static void
channel_gui_unregister(channel_T *channel)
{
if (channel->ch_pfd[CHAN_SOCK].ch_fd >= 0)
channel_gui_unregister_one(channel, CHAN_SOCK);
# ifdef CHANNEL_PIPES
if (channel->ch_pfd[CHAN_OUT].ch_fd >= 0)
channel_gui_unregister_one(channel, CHAN_OUT);
if (channel->ch_pfd[CHAN_ERR].ch_fd >= 0)
channel_gui_unregister_one(channel, CHAN_ERR);
# endif
} }
#endif #endif
@ -1192,16 +1189,14 @@ channel_close(channel_T *channel)
{ {
ch_log(channel, "Closing channel"); ch_log(channel, "Closing channel");
#ifdef FEAT_GUI
channel_gui_unregister(channel);
#endif
if (channel->CH_SOCK >= 0) if (channel->CH_SOCK >= 0)
{ {
sock_close(channel->CH_SOCK); sock_close(channel->CH_SOCK);
channel->CH_SOCK = -1; channel->CH_SOCK = -1;
channel->ch_close_cb = NULL;
#ifdef FEAT_GUI
channel_gui_unregister(channel);
#endif
vim_free(channel->ch_callback);
channel->ch_callback = NULL;
} }
#if defined(CHANNEL_PIPES) #if defined(CHANNEL_PIPES)
if (channel->CH_IN >= 0) if (channel->CH_IN >= 0)
@ -1220,6 +1215,10 @@ channel_close(channel_T *channel)
channel->CH_ERR = -1; channel->CH_ERR = -1;
} }
#endif #endif
channel->ch_close_cb = NULL;
vim_free(channel->ch_callback);
channel->ch_callback = NULL;
channel_clear(channel); channel_clear(channel);
} }
@ -1383,7 +1382,7 @@ channel_get_id(void)
/* /*
* Get the file descriptor to read from, either the socket or stdout. * Get the file descriptor to read from, either the socket or stdout.
* TODO: never gets stderr. * TODO: should have a way to read stderr.
*/ */
static int static int
get_read_fd(channel_T *channel) get_read_fd(channel_T *channel)
@ -1400,7 +1399,8 @@ get_read_fd(channel_T *channel)
/* /*
* Read from channel "channel" for as long as there is something to read. * Read from channel "channel" for as long as there is something to read.
* "which" is CHAN_SOCK, CHAN_OUT or CHAN_ERR. When -1 guess. * "which" is CHAN_SOCK, CHAN_OUT or CHAN_ERR. When -1 use CHAN_SOCK or
* CHAN_OUT, the one that is open.
* The data is put in the read queue. * The data is put in the read queue.
*/ */
void void
@ -1475,19 +1475,12 @@ channel_read(channel_T *channel, int which, char *func)
ch_errors(channel, "%s(): Cannot read\n", func); ch_errors(channel, "%s(): Cannot read\n", func);
channel_save(channel, (char_u *)DETACH_MSG, (int)STRLEN(DETACH_MSG)); channel_save(channel, (char_u *)DETACH_MSG, (int)STRLEN(DETACH_MSG));
if (use_socket) /* TODO: When reading from stdout is not possible, should we try to
{ * keep stdin and stderr open? Probably not, assume the other side
* has died. */
channel_close(channel); channel_close(channel);
if (channel->ch_close_cb != NULL) if (channel->ch_close_cb != NULL)
(*channel->ch_close_cb)(); (*channel->ch_close_cb)();
}
#if defined(CHANNEL_PIPES)
else
{
close(fd);
channel->CH_OUT = -1;
}
#endif
if (len < 0) if (len < 0)
{ {
@ -1587,6 +1580,7 @@ channel_fd2channel(sock_T fd, int *whichp)
if (fd >= 0) if (fd >= 0)
for (channel = first_channel; channel != NULL; for (channel = first_channel; channel != NULL;
channel = channel->ch_next) channel = channel->ch_next)
{
# ifdef CHANNEL_PIPES # ifdef CHANNEL_PIPES
for (i = CHAN_SOCK; i < CHAN_IN; ++i) for (i = CHAN_SOCK; i < CHAN_IN; ++i)
# else # else
@ -1595,7 +1589,8 @@ channel_fd2channel(sock_T fd, int *whichp)
if (channel->ch_pfd[i].ch_fd == fd) if (channel->ch_pfd[i].ch_fd == fd)
{ {
*whichp = i; *whichp = i;
return channel return channel;
}
} }
return NULL; return NULL;
} }
@ -1638,7 +1633,7 @@ channel_send(channel_T *channel, char_u *buf, char *fun)
{ {
ch_log_lead("SEND ", channel); ch_log_lead("SEND ", channel);
fprintf(log_fd, "'"); fprintf(log_fd, "'");
ignored = fwrite(buf, len, 1, log_fd); ignored = (int)fwrite(buf, len, 1, log_fd);
fprintf(log_fd, "'\n"); fprintf(log_fd, "'\n");
fflush(log_fd); fflush(log_fd);
} }
@ -1677,11 +1672,13 @@ channel_poll_setup(int nfd_in, void *fds_in)
int which; int which;
for (channel = first_channel; channel != NULL; channel = channel->ch_next) for (channel = first_channel; channel != NULL; channel = channel->ch_next)
{
# ifdef CHANNEL_PIPES # ifdef CHANNEL_PIPES
for (which = CHAN_SOCK; which < CHAN_IN; ++which) for (which = CHAN_SOCK; which < CHAN_IN; ++which)
# else # else
which = CHAN_SOCK; which = CHAN_SOCK;
# endif # endif
{
if (channel->ch_pfd[which].ch_fd >= 0) if (channel->ch_pfd[which].ch_fd >= 0)
{ {
channel->ch_pfd[which].ch_poll_idx = nfd; channel->ch_pfd[which].ch_poll_idx = nfd;
@ -1691,6 +1688,8 @@ channel_poll_setup(int nfd_in, void *fds_in)
} }
else else
channel->ch_pfd[which].ch_poll_idx = -1; channel->ch_pfd[which].ch_poll_idx = -1;
}
}
return nfd; return nfd;
} }
@ -1707,8 +1706,9 @@ channel_poll_check(int ret_in, void *fds_in)
int which; int which;
for (channel = first_channel; channel != NULL; channel = channel->ch_next) for (channel = first_channel; channel != NULL; channel = channel->ch_next)
{
# ifdef CHANNEL_PIPES # ifdef CHANNEL_PIPES
for (which = CHAN_SOCK; which < CHAN_IN; ++which) for (which = CHAN_SOCK; which < CH_IN; ++which)
# else # else
which = CHAN_SOCK; which = CHAN_SOCK;
# endif # endif
@ -1721,6 +1721,7 @@ channel_poll_check(int ret_in, void *fds_in)
--ret; --ret;
} }
} }
}
return ret; return ret;
} }
@ -1739,6 +1740,7 @@ channel_select_setup(int maxfd_in, void *rfds_in)
int which; int which;
for (channel = first_channel; channel != NULL; channel = channel->ch_next) for (channel = first_channel; channel != NULL; channel = channel->ch_next)
{
# ifdef CHANNEL_PIPES # ifdef CHANNEL_PIPES
for (which = CHAN_SOCK; which < CHAN_IN; ++which) for (which = CHAN_SOCK; which < CHAN_IN; ++which)
# else # else
@ -1754,6 +1756,7 @@ channel_select_setup(int maxfd_in, void *rfds_in)
maxfd = fd; maxfd = fd;
} }
} }
}
return maxfd; return maxfd;
} }
@ -1770,6 +1773,7 @@ channel_select_check(int ret_in, void *rfds_in)
int which; int which;
for (channel = first_channel; channel != NULL; channel = channel->ch_next) for (channel = first_channel; channel != NULL; channel = channel->ch_next)
{
# ifdef CHANNEL_PIPES # ifdef CHANNEL_PIPES
for (which = CHAN_SOCK; which < CHAN_IN; ++which) for (which = CHAN_SOCK; which < CHAN_IN; ++which)
# else # else
@ -1784,6 +1788,7 @@ channel_select_check(int ret_in, void *rfds_in)
--ret; --ret;
} }
} }
}
return ret; return ret;
} }

View File

@ -5043,7 +5043,7 @@ mch_start_job(char **argv, job_T *job)
int fd_in[2]; /* for stdin */ int fd_in[2]; /* for stdin */
int fd_out[2]; /* for stdout */ int fd_out[2]; /* for stdout */
int fd_err[2]; /* for stderr */ int fd_err[2]; /* for stderr */
channel_T *channel; channel_T *channel = NULL;
/* default is to fail */ /* default is to fail */
job->jv_status = JOB_FAILED; job->jv_status = JOB_FAILED;

View File

@ -22,10 +22,10 @@ char_u *channel_peek(channel_T *channel);
void channel_clear(channel_T *channel); void channel_clear(channel_T *channel);
void channel_free_all(void); void channel_free_all(void);
int channel_get_id(void); int channel_get_id(void);
void channel_read(channel_T *channel, int what, char *func); void channel_read(channel_T *channel, int which, char *func);
char_u *channel_read_block(channel_T *channel); char_u *channel_read_block(channel_T *channel);
int channel_read_json_block(channel_T *channel, int id, typval_T **rettv); int channel_read_json_block(channel_T *channel, int id, typval_T **rettv);
channel_T *channel_fd2channel(sock_T fd, int *what); channel_T *channel_fd2channel(sock_T fd, int *whichp);
int channel_send(channel_T *channel, char_u *buf, char *fun); int channel_send(channel_T *channel, char_u *buf, char *fun);
int channel_poll_setup(int nfd_in, void *fds_in); int channel_poll_setup(int nfd_in, void *fds_in);
int channel_poll_check(int ret_in, void *fds_in); int channel_poll_check(int ret_in, void *fds_in);

View File

@ -1301,8 +1301,8 @@ typedef enum
MODE_JS MODE_JS
} ch_mode_T; } ch_mode_T;
/* Ordering matters: IN is last, only SOCK/OUT/ERR are polled */ /* Ordering matters, it is used in for loops: IN is last, only SOCK/OUT/ERR
* are polled. */
#define CHAN_SOCK 0 #define CHAN_SOCK 0
#define CH_SOCK ch_pfd[CHAN_SOCK].ch_fd #define CH_SOCK ch_pfd[CHAN_SOCK].ch_fd
@ -1342,7 +1342,7 @@ struct channel_S {
int ch_id; /* ID of the channel */ int ch_id; /* ID of the channel */
chan_fd_T ch_pfd[4]; /* info for socket, in, out and err */ chan_fd_T ch_pfd[4]; /* info for socket, out, err and in */
readq_T ch_head; /* dummy node, header for circular queue */ readq_T ch_head; /* dummy node, header for circular queue */
@ -1351,6 +1351,7 @@ struct channel_S {
* the other side has exited, only mention the * the other side has exited, only mention the
* first error until the connection works * first error until the connection works
* again. */ * again. */
void (*ch_close_cb)(void); /* callback for when channel is closed */ void (*ch_close_cb)(void); /* callback for when channel is closed */
int ch_block_id; /* ID that channel_read_json_block() is int ch_block_id; /* ID that channel_read_json_block() is

View File

@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1319,
/**/ /**/
1318, 1318,
/**/ /**/