mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-09-02 15:02:51 +08:00
cmd: keep the history pointer inside the ring
The pointer is masked when it advances over the command text, then incremented once more for the newline without masking, so it can come to rest one past the end of the ring. Both readers walk from the pointer with their own index masked every step, so an index that sits outside the ring is never reached and the walk does not end. `history` on the console spins there, and so does `/cmd_log`, which the web page fetches whenever settings are saved: it fills the transmit buffer and keeps going past it.
This commit is contained in:
+2
-1
@@ -1771,7 +1771,8 @@ void cmd_parser(void) __banked
|
|||||||
// Copy last cmd-buffer to history.
|
// Copy last cmd-buffer to history.
|
||||||
cmd_history_ptr = (cmd_history_ptr + i) & CMD_HISTORY_MASK;
|
cmd_history_ptr = (cmd_history_ptr + i) & CMD_HISTORY_MASK;
|
||||||
__xdata uint16_t p = cmd_history_ptr;
|
__xdata uint16_t p = cmd_history_ptr;
|
||||||
cmd_history[cmd_history_ptr++] = '\n';
|
cmd_history[cmd_history_ptr] = '\n';
|
||||||
|
cmd_history_ptr = (cmd_history_ptr + 1) & CMD_HISTORY_MASK;
|
||||||
do {
|
do {
|
||||||
i--;
|
i--;
|
||||||
cmd_history[--p & CMD_HISTORY_MASK] = cmd_buffer[i];
|
cmd_history[--p & CMD_HISTORY_MASK] = cmd_buffer[i];
|
||||||
|
|||||||
Reference in New Issue
Block a user