From ecbbe96ec1236dbdd1c6bbad561e0eb17c55b1d9 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Mon, 18 Jan 2021 19:45:48 +0800 Subject: [PATCH] Waiting the remaining tcp data are sent So that the tcp socket are closed by debugger client first and the debugger client won't receive socket are closed by remote error JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com --- jerry-ext/debugger/debugger-tcp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/jerry-ext/debugger/debugger-tcp.c b/jerry-ext/debugger/debugger-tcp.c index d4292df5bf..244d305d5d 100644 --- a/jerry-ext/debugger/debugger-tcp.c +++ b/jerry-ext/debugger/debugger-tcp.c @@ -131,6 +131,16 @@ jerryx_debugger_tcp_close (jerry_debugger_transport_header_t *header_p) /**< tcp jerryx_debugger_transport_tcp_t *tcp_p = (jerryx_debugger_transport_tcp_t *) header_p; + /** + * Waiting the remaining tcp data are sent, so that the tcp socket are + * closed by debugger client first and the debugger client won't receive + * socket are closed by remote error + */ + for (int i = 0; i < 5; i += 1) + { + jerry_debugger_transport_sleep (); + } + JERRYX_DEBUG_MSG ("TCP connection closed.\n"); jerryx_debugger_tcp_close_socket (tcp_p->tcp_socket);