AP_Bootloader: added cleanup of web server threads
This commit is contained in:
parent
f7c7ee00e9
commit
2f71e023db
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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*);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user