Subject: Re: bug#11536: 23.4; frequent spurious auto-save while typing

From: Chong Yidong <[email-masked]>
Date: Sat, 03 Nov 2012 23:46:36 +0800

Jim Paris <[email-masked]> writes:

> The call to keyboard.c:set_waiting_for_input is essentially telling the
> keyboard.c:input_available_signal handler to reset &timeout to zero in
> the case of SIGIO.  However, consider what happens if a key is pressed
> and SIGIO is received between set_waiting_for_input and select.
> Then timeout will have been set to zero, and select will return
> immediately with nfds == 0.  The check in 5007 will then break the
> while loop, causing wait_reading_process_output to return immediately
> without any data having been read -- triggering the auto-save back
> in keyboard.c:read_char.
>
> It seems the fix is simple: remove lines 5007-5009.  It's a small
> optimization that isn't necessary, because the later check at line 5129
> already covers the case where nfds == 0.  Continuing the loop is fine,
> because the top of the loop checks for an expired timeout and returns.

Thanks for the bug report and the analysis.  I couldn't reproduce the
problem, but off the top of my head the analysis is correct, so I've
made the change you suggested in trunk.