From 8b05e856830826a9fb655072402454ed8b83dcd4 Mon Sep 17 00:00:00 2001 From: Nils <34674720+nils-kt@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:56:33 +0200 Subject: [PATCH] Refactor event handler logic to improve connection state management - Updated the event handler to ensure that the disconnected state is only bypassed if the connection is not in the listening state. - Enhanced the condition for returning early from the function to include a check for `disc_time` being zero, improving the handling of disconnection timeouts. --- src/event-handler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/event-handler.c b/src/event-handler.c index 9687fce..7e6acbd 100644 --- a/src/event-handler.c +++ b/src/event-handler.c @@ -374,7 +374,7 @@ void event_handler_tick(struct irl_source_data *data) if (state == CONN_STATE_CONNECTED) check_quality(data); - if (state != CONN_STATE_DISCONNECTED) + if (state != CONN_STATE_DISCONNECTED && state != CONN_STATE_LISTENING) return; pthread_mutex_lock(&data->mutex); @@ -383,7 +383,7 @@ void event_handler_tick(struct irl_source_data *data) int timeout = data->disconnect_timeout_sec; pthread_mutex_unlock(&data->mutex); - if (already_fired || timeout <= 0) + if (already_fired || timeout <= 0 || disc_time == 0) return; uint64_t elapsed_ns = os_gettime_ns() - disc_time;