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