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.
This commit is contained in:
Nils
2026-04-29 15:56:33 +02:00
parent d116e6a652
commit 8b05e85683
+2 -2
View File
@@ -374,7 +374,7 @@ void event_handler_tick(struct irl_source_data *data)
if (state == CONN_STATE_CONNECTED) if (state == CONN_STATE_CONNECTED)
check_quality(data); check_quality(data);
if (state != CONN_STATE_DISCONNECTED) if (state != CONN_STATE_DISCONNECTED && state != CONN_STATE_LISTENING)
return; return;
pthread_mutex_lock(&data->mutex); pthread_mutex_lock(&data->mutex);
@@ -383,7 +383,7 @@ void event_handler_tick(struct irl_source_data *data)
int timeout = data->disconnect_timeout_sec; int timeout = data->disconnect_timeout_sec;
pthread_mutex_unlock(&data->mutex); pthread_mutex_unlock(&data->mutex);
if (already_fired || timeout <= 0) if (already_fired || timeout <= 0 || disc_time == 0)
return; return;
uint64_t elapsed_ns = os_gettime_ns() - disc_time; uint64_t elapsed_ns = os_gettime_ns() - disc_time;