AP_Bootloader: added cleanup of web server threads

This commit is contained in:
Andrew Tridgell 2024-01-20 07:53:00 +11:00
parent f7c7ee00e9
commit 2f71e023db
2 changed files with 18 additions and 0 deletions

View File

@ -539,7 +539,14 @@ void BL_Network::net_request_trampoline(void *ctx)
{
auto *req = (req_context *)ctx;
req->driver->handle_request(req->sock);
auto *driver = req->driver;
auto *thd = chThdGetSelfX();
delete req;
WITH_SEMAPHORE(driver->web_delete_mtx);
thd->delete_next = driver->web_delete_list;
driver->web_delete_list = thd;
}
/*
@ -574,6 +581,14 @@ void BL_Network::web_server(void)
60,
net_request_trampoline,
req);
// cleanup any finished threads
WITH_SEMAPHORE(web_delete_mtx);
while (web_delete_list != nullptr) {
auto *thd = web_delete_list;
web_delete_list = thd->delete_next;
chThdRelease(thd);
}
}
}

View File

@ -19,6 +19,9 @@ private:
struct netif *thisif;
thread_t *net_thread_ctx;
HAL_Semaphore web_delete_mtx;
thread_t *web_delete_list;
static void net_thread_trampoline(void*);
static void web_server_trampoline(void*);