diff options
| author | Jan D | 2010-07-07 19:39:49 +0200 |
|---|---|---|
| committer | Jan D | 2010-07-07 19:39:49 +0200 |
| commit | cb768704a459ab54632daf5bb1a10127a6a5c9f7 (patch) | |
| tree | f4f9018ea6563a1eee13550f9a8bc89731f0ad25 /src/process.c | |
| parent | 3a8ce8225692c705bb0dde88acb62bda6e688158 (diff) | |
| download | emacs-cb768704a459ab54632daf5bb1a10127a6a5c9f7.tar.gz emacs-cb768704a459ab54632daf5bb1a10127a6a5c9f7.zip | |
If kbd_buffer is becoming full, stop reading until it drains (Bug#6571).
* keyboard.c (input_available_signal): Declare.
(kbd_buffer_nr_stored): New function.
(kbd_buffer_store_event_hold): If kbd_buffer_nr_stored returns
more than KBD_BUFFER_SIZE/2, stop reding input (Bug#6571).
(kbd_buffer_get_event): If input is suspended and kbd_buffer_nr_stored
returns less than KBD_BUFFER_SIZE/4, resume reding input (Bug#6571).
(tty_read_avail_input): If input is on hold, return.
Don't read more that free slots in kbd_buffer (Bug#6571).
* process.h (hold_keyboard_input, unhold_keyboard_input)
(kbd_on_hold_p): Declare.
* process.c (kbd_is_on_hold): New variable.
(hold_keyboard_input, unhold_keyboard_input, kbd_on_hold_p): New
functions.
(wait_reading_process_output): If kbd_on_hold_p returns non-zero,
select on empty input mask.
(init_process): Initialize kbd_is_on_hold to 0.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/process.c b/src/process.c index 0807a0e17cb..c7460d81255 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -306,6 +306,10 @@ extern int timers_run; | |||
| 306 | 306 | ||
| 307 | static SELECT_TYPE input_wait_mask; | 307 | static SELECT_TYPE input_wait_mask; |
| 308 | 308 | ||
| 309 | /* Non-zero if keyboard input is on hold, zero otherwise. */ | ||
| 310 | |||
| 311 | static int kbd_is_on_hold; | ||
| 312 | |||
| 309 | /* Mask that excludes keyboard input descriptor(s). */ | 313 | /* Mask that excludes keyboard input descriptor(s). */ |
| 310 | 314 | ||
| 311 | static SELECT_TYPE non_keyboard_wait_mask; | 315 | static SELECT_TYPE non_keyboard_wait_mask; |
| @@ -4731,7 +4735,10 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 4731 | SELECT_TYPE Ctemp; | 4735 | SELECT_TYPE Ctemp; |
| 4732 | #endif | 4736 | #endif |
| 4733 | 4737 | ||
| 4734 | Atemp = input_wait_mask; | 4738 | if (kbd_on_hold_p ()) |
| 4739 | FD_ZERO (&Atemp); | ||
| 4740 | else | ||
| 4741 | Atemp = input_wait_mask; | ||
| 4735 | IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); | 4742 | IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); |
| 4736 | 4743 | ||
| 4737 | EMACS_SET_SECS_USECS (timeout, 0, 0); | 4744 | EMACS_SET_SECS_USECS (timeout, 0, 0); |
| @@ -7010,6 +7017,30 @@ DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p, | |||
| 7010 | 7017 | ||
| 7011 | 7018 | ||
| 7012 | 7019 | ||
| 7020 | /* Stop reading input from keyboard sources. */ | ||
| 7021 | |||
| 7022 | void | ||
| 7023 | hold_keyboard_input (void) | ||
| 7024 | { | ||
| 7025 | kbd_is_on_hold = 1; | ||
| 7026 | } | ||
| 7027 | |||
| 7028 | /* Resume reading input from keyboard sources. */ | ||
| 7029 | |||
| 7030 | void | ||
| 7031 | unhold_keyboard_input (void) | ||
| 7032 | { | ||
| 7033 | kbd_is_on_hold = 0; | ||
| 7034 | } | ||
| 7035 | |||
| 7036 | /* Return non-zero if keyboard input is on hold, zero otherwise. */ | ||
| 7037 | |||
| 7038 | int | ||
| 7039 | kbd_on_hold_p (void) | ||
| 7040 | { | ||
| 7041 | return kbd_is_on_hold; | ||
| 7042 | } | ||
| 7043 | |||
| 7013 | /* Add DESC to the set of keyboard input descriptors. */ | 7044 | /* Add DESC to the set of keyboard input descriptors. */ |
| 7014 | 7045 | ||
| 7015 | void | 7046 | void |
| @@ -7901,6 +7932,7 @@ integer or floating point values. | |||
| 7901 | void | 7932 | void |
| 7902 | init_process () | 7933 | init_process () |
| 7903 | { | 7934 | { |
| 7935 | kbd_is_on_hold = 0; | ||
| 7904 | } | 7936 | } |
| 7905 | 7937 | ||
| 7906 | void | 7938 | void |