From 174d13339f53273a3cf4fb5e6703d2d15567fce1 Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 6 Oct 2022 18:52:53 +0200 Subject: [PATCH] Restart the server on error --- src/BackgroundThread.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/BackgroundThread.cpp b/src/BackgroundThread.cpp index 9339454..33b3d24 100644 --- a/src/BackgroundThread.cpp +++ b/src/BackgroundThread.cpp @@ -38,8 +38,14 @@ BOOL BackgroundThread::whileLoop() { this->serverSocket = -1; DCFlushRange(&(this->serverSocket), 4); } + } else { + this->serverSocket = create_server(PORT); + if (this->serverSocket < 0) { + DEBUG_FUNCTION_LINE_WARN("Creating a new ftp server failed. Trying again in 5 seconds."); + OSSleepTicks(OSSecondsToTicks(5)); + } } mutex.unlock(); - OSSleepTicks(OSMillisecondsToTicks(16)); + OSSleepTicks(OSMillisecondsToTicks(1)); return true; }