Skip to content

Commit 8fdd721

Browse files
committed
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.
1 parent 92e35ef commit 8fdd721

2 files changed

Lines changed: 28 additions & 15 deletions

File tree

src/os_unix.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ typedef int waitstatus;
176176
static pid_t wait4pid(pid_t, waitstatus *);
177177

178178
static int WaitForChar(long);
179-
static int WaitForCharOrMouse(long);
179+
static int WaitForCharOrMouse(long, int *break_loop);
180180
#if defined(__BEOS__) || defined(VMS)
181-
int RealWaitForChar(int, long, int *);
181+
int RealWaitForChar(int, long, int *, int *break_loop);
182182
#else
183-
static int RealWaitForChar(int, long, int *);
183+
static int RealWaitForChar(int, long, int *, int *break_loop);
184184
#endif
185185

186186
#ifdef FEAT_XCLIPBOARD
@@ -366,7 +366,7 @@ mch_write(char_u *s, int len)
366366
{
367367
ignored = (int)write(1, (char *)s, len);
368368
if (p_wd) /* Unix is too fast, slow down a bit more */
369-
RealWaitForChar(read_cmd_fd, p_wd, NULL);
369+
RealWaitForChar(read_cmd_fd, p_wd, NULL, NULL);
370370
}
371371

372372
/*
@@ -4762,7 +4762,7 @@ mch_call_shell(
47624762
* to some terminal (vt52?).
47634763
*/
47644764
++noread_cnt;
4765-
while (RealWaitForChar(fromshell_fd, 10L, NULL))
4765+
while (RealWaitForChar(fromshell_fd, 10L, NULL, NULL))
47664766
{
47674767
len = read_eintr(fromshell_fd, buffer
47684768
# ifdef FEAT_MBYTE
@@ -5343,7 +5343,7 @@ mch_clear_job(job_T *job)
53435343
void
53445344
mch_breakcheck(void)
53455345
{
5346-
if (curr_tmode == TMODE_RAW && RealWaitForChar(read_cmd_fd, 0L, NULL))
5346+
if (curr_tmode == TMODE_RAW && RealWaitForChar(read_cmd_fd, 0L, NULL, NULL))
53475347
fill_input_buf(FALSE);
53485348
}
53495349

@@ -5360,10 +5360,11 @@ WaitForChar(long msec)
53605360
#ifdef FEAT_TIMERS
53615361
long due_time;
53625362
long remaining = msec;
5363+
int break_loop = FALSE;
53635364

53645365
/* When waiting very briefly don't trigger timers. */
53655366
if (msec >= 0 && msec < 10L)
5366-
return WaitForCharOrMouse(msec);
5367+
return WaitForCharOrMouse(msec, NULL);
53675368

53685369
while (msec < 0 || remaining > 0)
53695370
{
@@ -5372,14 +5373,18 @@ WaitForChar(long msec)
53725373
due_time = check_due_timer();
53735374
if (due_time <= 0 || (msec > 0 && due_time > remaining))
53745375
due_time = remaining;
5375-
if (WaitForCharOrMouse(due_time))
5376+
if (WaitForCharOrMouse(due_time, &break_loop))
53765377
return TRUE;
5378+
if (break_loop)
5379+
/* Nothing available, but need to return so that side effects get
5380+
* handled, such as handling a message on a channel. */
5381+
return FALSE;
53775382
if (msec > 0)
53785383
remaining -= due_time;
53795384
}
53805385
return FALSE;
53815386
#else
5382-
return WaitForCharOrMouse(msec);
5387+
return WaitForCharOrMouse(msec, NULL);
53835388
#endif
53845389
}
53855390

@@ -5390,7 +5395,7 @@ WaitForChar(long msec)
53905395
* When a GUI is being used, this will never get called -- webb
53915396
*/
53925397
static int
5393-
WaitForCharOrMouse(long msec)
5398+
WaitForCharOrMouse(long msec, int *break_loop)
53945399
{
53955400
#ifdef FEAT_MOUSE_GPM
53965401
int gpm_process_wanted;
@@ -5436,9 +5441,10 @@ WaitForCharOrMouse(long msec)
54365441
# endif
54375442
# ifdef FEAT_MOUSE_GPM
54385443
gpm_process_wanted = 0;
5439-
avail = RealWaitForChar(read_cmd_fd, msec, &gpm_process_wanted);
5444+
avail = RealWaitForChar(read_cmd_fd, msec,
5445+
&gpm_process_wanted, break_loop);
54405446
# else
5441-
avail = RealWaitForChar(read_cmd_fd, msec, NULL);
5447+
avail = RealWaitForChar(read_cmd_fd, msec, NULL, break_loop);
54425448
# endif
54435449
if (!avail)
54445450
{
@@ -5457,10 +5463,11 @@ WaitForCharOrMouse(long msec)
54575463
# ifdef FEAT_XCLIPBOARD
54585464
|| (!avail && rest != 0)
54595465
# endif
5460-
);
5466+
)
5467+
;
54615468

54625469
#else
5463-
avail = RealWaitForChar(read_cmd_fd, msec, NULL);
5470+
avail = RealWaitForChar(read_cmd_fd, msec, NULL, &break_loop);
54645471
#endif
54655472
return avail;
54665473
}
@@ -5479,7 +5486,7 @@ WaitForCharOrMouse(long msec)
54795486
#else
54805487
static int
54815488
#endif
5482-
RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED)
5489+
RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *break_loop)
54835490
{
54845491
int ret;
54855492
int result;
@@ -5592,6 +5599,8 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED)
55925599
ret = poll(fds, nfd, towait);
55935600

55945601
result = ret > 0 && (fds[0].revents & POLLIN);
5602+
if (break_loop != NULL && ret > 0)
5603+
*break_loop = TRUE;
55955604

55965605
# ifdef FEAT_MZSCHEME
55975606
if (ret == 0 && mzquantum_used)
@@ -5723,6 +5732,8 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED)
57235732
result = ret > 0 && FD_ISSET(fd, &rfds);
57245733
if (result)
57255734
--ret;
5735+
if (break_loop != NULL && ret > 0)
5736+
*break_loop = TRUE;
57265737

57275738
# ifdef EINTR
57285739
if (ret == -1 && errno == EINTR)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ static char *(features[]) =
748748

749749
static int included_patches[] =
750750
{ /* Add new patch number below this line */
751+
/**/
752+
1657,
751753
/**/
752754
1656,
753755
/**/

0 commit comments

Comments
 (0)