From 258e93d01e4498a0a9280052d496e76182f9d3cb Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 6 Oct 2022 18:55:52 +0200 Subject: [PATCH] Increase the sleep duration if no client is connected. --- src/BackgroundThread.cpp | 1 - src/ftp.c | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/BackgroundThread.cpp b/src/BackgroundThread.cpp index 42706be..322929e 100644 --- a/src/BackgroundThread.cpp +++ b/src/BackgroundThread.cpp @@ -42,6 +42,5 @@ BOOL BackgroundThread::whileLoop() { OSSleepTicks(OSSecondsToTicks(5)); } } - OSSleepTicks(OSMillisecondsToTicks(1)); return true; } diff --git a/src/ftp.c b/src/ftp.c index db5f8da..5867c2e 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -958,9 +958,11 @@ recv_loop_end: bool process_ftp_events(int32_t server) { bool network_down = !process_accept_events(server); int client_index; + bool hasActiveClients = false; for (client_index = 0; client_index < MAX_CLIENTS; client_index++) { client_t *client = clients[client_index]; if (client) { + hasActiveClients = true; if (client->data_callback) { process_data_events(client); } else { @@ -968,5 +970,10 @@ bool process_ftp_events(int32_t server) { } } } + if (!hasActiveClients) { + OSSleepTicks(OSMillisecondsToTicks(100)); + } else { + OSSleepTicks(OSMillisecondsToTicks(1)); + } return network_down; }