Browse Source

minor bug fixed for device parse thread crush,
when system is closing.

yct 3 years ago
parent
commit
c69c190712
1 changed files with 5 additions and 12 deletions
  1. 5 12
      velodyne_lidar/velodyne_driver/velodyne_lidar_device.cpp

+ 5 - 12
velodyne_lidar/velodyne_driver/velodyne_lidar_device.cpp

@@ -131,39 +131,30 @@ Error_manager Velodyne_lidar_device::init(velodyne::velodyneLidarParams params)
 //反初始化
 Error_manager Velodyne_lidar_device::uninit()
 {
-	//终止队列,防止 wait_and_pop 阻塞线程。
-	m_communication_data_queue.termination_queue();
 
 	if (mp_capture_thread)
 	{
 		m_capture_condition.kill_all();
-	}
-	if (mp_capture_thread)
-	{
 		mp_capture_thread->join();
 		delete mp_capture_thread;
 		mp_capture_thread = NULL;
 	}
 
+	// //终止队列,防止 wait_and_pop 阻塞线程。
+	m_communication_data_queue.termination_queue();
 	if (mp_parse_thread)
 	{
 		m_parse_condition.kill_all();
-	}
-	if (mp_parse_thread)
-	{
 		mp_parse_thread->join();
 		delete mp_parse_thread;
 		mp_parse_thread = NULL;
 	}
 
 	//关闭线程
-	if (mp_execute_thread)
-	{
-		m_execute_condition.kill_all();
-	}
 	//回收线程的资源
 	if (mp_execute_thread)
 	{
+		m_execute_condition.kill_all();
 		mp_execute_thread->join();
 		delete mp_execute_thread;
 		mp_execute_thread = NULL;
@@ -551,7 +542,9 @@ void Velodyne_lidar_device::parse_thread_fun()
 				m_velodyne_protocol_status = E_BUSY;
 			if (m_protocol.isInitialized())
 			{
+				// LOG(INFO) << "11111";
 				Binary_buf *buf = *m_communication_data_queue.wait_and_pop();
+				// LOG(INFO) << "22222";
 				if (buf != nullptr)
 				{
 					std::lock_guard<std::mutex> lck(m_cloud_mutex);