Fixed disconnect crash/loop

This commit is contained in:
y4my4my4m 2023-05-26 02:17:18 +09:00
parent c7ccedb2f0
commit 34177b0420

View file

@ -681,7 +681,7 @@ U0 ANSIParse()
} }
U0 TerminalTask() { U0 TerminalTask() {
while (!term.sock_ready) { while (!term.sock_ready) {
Sleep(100); // Avoid busy waiting Sleep(100); // Avoid busy waiting
} }
@ -907,16 +907,13 @@ init_connection:
case CH_BACKSPACE: case CH_BACKSPACE:
if (term.sock_ready) TCPSocketSendString(term.sock, "\x08\x7F"); if (term.sock_ready) TCPSocketSendString(term.sock, "\x08\x7F");
break; break;
case CH_ESC:
if (term.sock_ready) TCPSocketSendString(term.sock, "\x1B");
break;
case CH_SHIFT_ESC: case CH_SHIFT_ESC:
if (term.sock_ready) if (term.sock_ready)
{ {
if (term.sock_ready) TCPSocketClose(term.sock);
host = NULL;
term.sock_ready = 0;
term.waiting_for_input = TRUE; term.waiting_for_input = TRUE;
term.sock_ready = 0;
host = NULL;
TCPSocketClose(term.sock);
DocClear; DocClear;
"Telnet connection closed.\n"; "Telnet connection closed.\n";
Sleep(100); Sleep(100);
@ -925,6 +922,9 @@ init_connection:
else else
force_disconnect = TRUE; force_disconnect = TRUE;
break; break;
case CH_ESC:
if (term.sock_ready) TCPSocketSendString(term.sock, "\x1B");
break;
// send buffer on enter // send buffer on enter
case '\n': case '\n':
if (term.sock_ready) TCPSocketSendString(term.sock, "\r\n"); if (term.sock_ready) TCPSocketSendString(term.sock, "\r\n");