From 35d8088b447527f56609b85b444bd0b10cd67b5c Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Fri, 13 Dec 2019 10:51:25 +0100 Subject: [PATCH] Handle socket errors from connected clients. If a TLS error occurs, it could end up in a situation where the network handler code did not want to read or write because it only had the error flag set. However, this was not handled, which left the socket triggering in the event loop - but nothing was done to handle it. This can easily cause a 100% cpu situation - the hub is still functioning though while this is happening. --- src/core/netevent.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/netevent.c b/src/core/netevent.c index c7c51ef..ff96876 100644 --- a/src/core/netevent.c +++ b/src/core/netevent.c @@ -137,6 +137,12 @@ void net_event(struct net_connection* con, int event, void *arg) LOG_TRACE("net_event() : fd=%d, ev=%d, arg=%p", con->sd, (int) event, arg); #endif + if (event == NET_EVENT_ERROR) + { + hub_disconnect_user(user->hub, user, quit_socket_error); + return; + } + if (event == NET_EVENT_TIMEOUT) { if (user_is_connecting(user))