mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Proper termination of UAVACN server thread
This commit is contained in:
parent
9d86dbb6a1
commit
5b9fc2d9fa
@ -141,13 +141,14 @@ int UavcanServers::stop()
|
||||
return -1;
|
||||
}
|
||||
|
||||
_instance = nullptr;
|
||||
|
||||
if (server->_subnode_thread != -1) {
|
||||
pthread_cancel(server->_subnode_thread);
|
||||
pthread_join(server->_subnode_thread, NULL);
|
||||
if (server->_subnode_thread) {
|
||||
warnx("stopping fw srv thread...");
|
||||
server->_subnode_thread_should_exit = true;
|
||||
(void)pthread_join(server->_subnode_thread, NULL);
|
||||
}
|
||||
|
||||
_instance = nullptr;
|
||||
|
||||
server->_main_node.getDispatcher().removeRxFrameListener();
|
||||
|
||||
delete server;
|
||||
@ -334,7 +335,7 @@ pthread_addr_t UavcanServers::run(pthread_addr_t)
|
||||
memset(_esc_enumeration_ids, 0, sizeof(_esc_enumeration_ids));
|
||||
_esc_enumeration_index = 0;
|
||||
|
||||
while (1) {
|
||||
while (!_subnode_thread_should_exit) {
|
||||
|
||||
if (_check_fw == true) {
|
||||
_check_fw = false;
|
||||
@ -554,7 +555,9 @@ pthread_addr_t UavcanServers::run(pthread_addr_t)
|
||||
}
|
||||
}
|
||||
|
||||
warnx("exiting.");
|
||||
_subnode_thread_should_exit = false;
|
||||
|
||||
warnx("exiting");
|
||||
return (pthread_addr_t) 0;
|
||||
}
|
||||
|
||||
|
||||
@ -110,6 +110,7 @@ public:
|
||||
private:
|
||||
pthread_t _subnode_thread;
|
||||
pthread_mutex_t _subnode_mutex;
|
||||
volatile bool _subnode_thread_should_exit = false;
|
||||
|
||||
int init();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user