1
0
forked from aniani/vim

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.
This commit is contained in:
Bram Moolenaar
2016-03-26 19:41:48 +01:00
parent 92e35efaf6
commit 8fdd721047
2 changed files with 28 additions and 15 deletions

View File

@@ -176,11 +176,11 @@ typedef int waitstatus;
static pid_t wait4pid(pid_t, waitstatus *); static pid_t wait4pid(pid_t, waitstatus *);
static int WaitForChar(long); static int WaitForChar(long);
static int WaitForCharOrMouse(long); static int WaitForCharOrMouse(long, int *break_loop);
#if defined(__BEOS__) || defined(VMS) #if defined(__BEOS__) || defined(VMS)
int RealWaitForChar(int, long, int *); int RealWaitForChar(int, long, int *, int *break_loop);
#else #else
static int RealWaitForChar(int, long, int *); static int RealWaitForChar(int, long, int *, int *break_loop);
#endif #endif
#ifdef FEAT_XCLIPBOARD #ifdef FEAT_XCLIPBOARD
@@ -366,7 +366,7 @@ mch_write(char_u *s, int len)
{ {
ignored = (int)write(1, (char *)s, len); ignored = (int)write(1, (char *)s, len);
if (p_wd) /* Unix is too fast, slow down a bit more */ if (p_wd) /* Unix is too fast, slow down a bit more */
RealWaitForChar(read_cmd_fd, p_wd, NULL); RealWaitForChar(read_cmd_fd, p_wd, NULL, NULL);
} }
/* /*
@@ -4762,7 +4762,7 @@ mch_call_shell(
* to some terminal (vt52?). * to some terminal (vt52?).
*/ */
++noread_cnt; ++noread_cnt;
while (RealWaitForChar(fromshell_fd, 10L, NULL)) while (RealWaitForChar(fromshell_fd, 10L, NULL, NULL))
{ {
len = read_eintr(fromshell_fd, buffer len = read_eintr(fromshell_fd, buffer
# ifdef FEAT_MBYTE # ifdef FEAT_MBYTE
@@ -5343,7 +5343,7 @@ mch_clear_job(job_T *job)
void void
mch_breakcheck(void) mch_breakcheck(void)
{ {
if (curr_tmode == TMODE_RAW && RealWaitForChar(read_cmd_fd, 0L, NULL)) if (curr_tmode == TMODE_RAW && RealWaitForChar(read_cmd_fd, 0L, NULL, NULL))
fill_input_buf(FALSE); fill_input_buf(FALSE);
} }
@@ -5360,10 +5360,11 @@ WaitForChar(long msec)
#ifdef FEAT_TIMERS #ifdef FEAT_TIMERS
long due_time; long due_time;
long remaining = msec; long remaining = msec;
int break_loop = FALSE;
/* When waiting very briefly don't trigger timers. */ /* When waiting very briefly don't trigger timers. */
if (msec >= 0 && msec < 10L) if (msec >= 0 && msec < 10L)
return WaitForCharOrMouse(msec); return WaitForCharOrMouse(msec, NULL);
while (msec < 0 || remaining > 0) while (msec < 0 || remaining > 0)
{ {
@@ -5372,14 +5373,18 @@ WaitForChar(long msec)
due_time = check_due_timer(); due_time = check_due_timer();
if (due_time <= 0 || (msec > 0 && due_time > remaining)) if (due_time <= 0 || (msec > 0 && due_time > remaining))
due_time = remaining; due_time = remaining;
if (WaitForCharOrMouse(due_time)) if (WaitForCharOrMouse(due_time, &break_loop))
return TRUE; 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) if (msec > 0)
remaining -= due_time; remaining -= due_time;
} }
return FALSE; return FALSE;
#else #else
return WaitForCharOrMouse(msec); return WaitForCharOrMouse(msec, NULL);
#endif #endif
} }
@@ -5390,7 +5395,7 @@ WaitForChar(long msec)
* When a GUI is being used, this will never get called -- webb * When a GUI is being used, this will never get called -- webb
*/ */
static int static int
WaitForCharOrMouse(long msec) WaitForCharOrMouse(long msec, int *break_loop)
{ {
#ifdef FEAT_MOUSE_GPM #ifdef FEAT_MOUSE_GPM
int gpm_process_wanted; int gpm_process_wanted;
@@ -5436,9 +5441,10 @@ WaitForCharOrMouse(long msec)
# endif # endif
# ifdef FEAT_MOUSE_GPM # ifdef FEAT_MOUSE_GPM
gpm_process_wanted = 0; gpm_process_wanted = 0;
avail = RealWaitForChar(read_cmd_fd, msec, &gpm_process_wanted); avail = RealWaitForChar(read_cmd_fd, msec,
&gpm_process_wanted, break_loop);
# else # else
avail = RealWaitForChar(read_cmd_fd, msec, NULL); avail = RealWaitForChar(read_cmd_fd, msec, NULL, break_loop);
# endif # endif
if (!avail) if (!avail)
{ {
@@ -5457,10 +5463,11 @@ WaitForCharOrMouse(long msec)
# ifdef FEAT_XCLIPBOARD # ifdef FEAT_XCLIPBOARD
|| (!avail && rest != 0) || (!avail && rest != 0)
# endif # endif
); )
;
#else #else
avail = RealWaitForChar(read_cmd_fd, msec, NULL); avail = RealWaitForChar(read_cmd_fd, msec, NULL, &break_loop);
#endif #endif
return avail; return avail;
} }
@@ -5479,7 +5486,7 @@ WaitForCharOrMouse(long msec)
#else #else
static int static int
#endif #endif
RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED) RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *break_loop)
{ {
int ret; int ret;
int result; int result;
@@ -5592,6 +5599,8 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED)
ret = poll(fds, nfd, towait); ret = poll(fds, nfd, towait);
result = ret > 0 && (fds[0].revents & POLLIN); result = ret > 0 && (fds[0].revents & POLLIN);
if (break_loop != NULL && ret > 0)
*break_loop = TRUE;
# ifdef FEAT_MZSCHEME # ifdef FEAT_MZSCHEME
if (ret == 0 && mzquantum_used) if (ret == 0 && mzquantum_used)
@@ -5723,6 +5732,8 @@ select_eintr:
result = ret > 0 && FD_ISSET(fd, &rfds); result = ret > 0 && FD_ISSET(fd, &rfds);
if (result) if (result)
--ret; --ret;
if (break_loop != NULL && ret > 0)
*break_loop = TRUE;
# ifdef EINTR # ifdef EINTR
if (ret == -1 && errno == EINTR) if (ret == -1 && errno == EINTR)

View File

@@ -748,6 +748,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 */
/**/
1657,
/**/ /**/
1656, 1656,
/**/ /**/