aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorEli Zaretskii1998-06-21 14:52:08 +0000
committerEli Zaretskii1998-06-21 14:52:08 +0000
commit52fd88d3c4a1a3e07b697508010c5526bf750340 (patch)
treea89c5b1fabe5831cc0dbb11429d2aeed2f12c909 /src/process.c
parent87a00c4f91fa3a744b06d7733c78bcec8d6842b2 (diff)
downloademacs-52fd88d3c4a1a3e07b697508010c5526bf750340.tar.gz
emacs-52fd88d3c4a1a3e07b697508010c5526bf750340.zip
(wait_reading_process_input): Recompute timeout each
time through the loop. Check requeued_events_pending_p and exit the loop if there is unread keyboard input.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/process.c b/src/process.c
index a9355968590..814fbc4a747 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4525,6 +4525,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4525 Lisp_Object read_kbd; 4525 Lisp_Object read_kbd;
4526 int do_display; 4526 int do_display;
4527{ 4527{
4528 register int nfds;
4528 EMACS_TIME end_time, timeout; 4529 EMACS_TIME end_time, timeout;
4529 SELECT_TYPE waitchannels; 4530 SELECT_TYPE waitchannels;
4530 int xerrno; 4531 int xerrno;
@@ -4540,27 +4541,17 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4540 /* What does time_limit really mean? */ 4541 /* What does time_limit really mean? */
4541 if (time_limit || microsecs) 4542 if (time_limit || microsecs)
4542 { 4543 {
4543 if (time_limit == -1)
4544 /* In fact, it's zero. */
4545 EMACS_SET_SECS_USECS (timeout, 0, 0);
4546 else
4547 EMACS_SET_SECS_USECS (timeout, time_limit, microsecs);
4548
4549 /* How far in the future is that? */
4550 EMACS_GET_TIME (end_time); 4544 EMACS_GET_TIME (end_time);
4545 EMACS_SET_SECS_USECS (timeout, time_limit, microsecs);
4551 EMACS_ADD_TIME (end_time, end_time, timeout); 4546 EMACS_ADD_TIME (end_time, end_time, timeout);
4552 } 4547 }
4553 else
4554 /* It's infinite. */
4555 EMACS_SET_SECS_USECS (timeout, 100000, 0);
4556 4548
4557 /* Turn off periodic alarms (in case they are in use) 4549 /* Turn off periodic alarms (in case they are in use)
4558 because the select emulator uses alarms. */ 4550 because the select emulator uses alarms. */
4559 stop_polling (); 4551 stop_polling ();
4560 4552
4561 for (;;) 4553 while (1)
4562 { 4554 {
4563 int nfds;
4564 int timeout_reduced_for_timers = 0; 4555 int timeout_reduced_for_timers = 0;
4565 4556
4566 /* If calling from keyboard input, do not quit 4557 /* If calling from keyboard input, do not quit
@@ -4575,13 +4566,25 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4575 4566
4576 /* Compute time from now till when time limit is up */ 4567 /* Compute time from now till when time limit is up */
4577 /* Exit if already run out */ 4568 /* Exit if already run out */
4578 if (time_limit > 0 || microsecs) 4569 if (time_limit == -1)
4570 {
4571 /* -1 specified for timeout means
4572 gobble output available now
4573 but don't wait at all. */
4574
4575 EMACS_SET_SECS_USECS (timeout, 0, 0);
4576 }
4577 else if (time_limit || microsecs)
4579 { 4578 {
4580 EMACS_GET_TIME (timeout); 4579 EMACS_GET_TIME (timeout);
4581 EMACS_SUB_TIME (timeout, end_time, timeout); 4580 EMACS_SUB_TIME (timeout, end_time, timeout);
4582 if (EMACS_TIME_NEG_P (timeout)) 4581 if (EMACS_TIME_NEG_P (timeout))
4583 break; 4582 break;
4584 } 4583 }
4584 else
4585 {
4586 EMACS_SET_SECS_USECS (timeout, 100000, 0);
4587 }
4585 4588
4586 /* If our caller will not immediately handle keyboard events, 4589 /* If our caller will not immediately handle keyboard events,
4587 run timer events directly. 4590 run timer events directly.
@@ -4603,6 +4606,11 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4603 goto retry; 4606 goto retry;
4604 } 4607 }
4605 4608
4609 /* If there is unread keyboard input, also return. */
4610 if (XINT (read_kbd) != 0
4611 && requeued_events_pending_p ())
4612 break;
4613
4606 if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1) 4614 if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1)
4607 { 4615 {
4608 EMACS_TIME difference; 4616 EMACS_TIME difference;
@@ -4687,6 +4695,11 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4687 break; 4695 break;
4688 } 4696 }
4689 4697
4698 /* If there is unread keyboard input, also return. */
4699 if (XINT (read_kbd) != 0
4700 && requeued_events_pending_p ())
4701 break;
4702
4690 /* If wait_for_cell. check for keyboard input 4703 /* If wait_for_cell. check for keyboard input
4691 but don't run any timers. 4704 but don't run any timers.
4692 ??? (It seems wrong to me to check for keyboard 4705 ??? (It seems wrong to me to check for keyboard