Increase the sleep duration if no client is connected.

This commit is contained in:
Maschell 2022-10-06 18:55:52 +02:00
parent 48eac1549e
commit 258e93d01e
2 changed files with 7 additions and 1 deletions

View File

@ -42,6 +42,5 @@ BOOL BackgroundThread::whileLoop() {
OSSleepTicks(OSSecondsToTicks(5));
}
}
OSSleepTicks(OSMillisecondsToTicks(1));
return true;
}

View File

@ -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;
}