From 5ad546ab1211175df8cff853b0048e43349dacd7 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 2 Feb 2024 11:06:28 +0100 Subject: [PATCH] sys/net/telnet: fix race condition on disconnect --- sys/net/application_layer/telnet/telnet_server.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/net/application_layer/telnet/telnet_server.c b/sys/net/application_layer/telnet/telnet_server.c index c0ab3d82be686..6f0528580ba18 100644 --- a/sys/net/application_layer/telnet/telnet_server.c +++ b/sys/net/application_layer/telnet/telnet_server.c @@ -123,6 +123,10 @@ static void _disconnect(void) DEBUG("telnet disconnect\n"); telnet_cb_disconneced(); + + _acquire(); + sock_tcp_disconnect(client); + _release(); } static int _write_buffer(const void* buffer, size_t len) @@ -268,7 +272,6 @@ static void *telnet_thread(void *arg) } disco: _disconnect(); - sock_tcp_disconnect(client); if (res < 0) { DEBUG("telnet: read: %s\n", strerror(res));