add missing checks for rmw return codes
This commit is contained in:
		
							parent
							
								
									3bc43653d1
								
							
						
					
					
						commit
						d98e3fe427
					
				
					 3 changed files with 27 additions and 7 deletions
				
			
		| 
						 | 
					@ -52,8 +52,11 @@ public:
 | 
				
			||||||
  virtual ~Executor()
 | 
					  virtual ~Executor()
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    if (interrupt_guard_condition_ != nullptr) {
 | 
					    if (interrupt_guard_condition_ != nullptr) {
 | 
				
			||||||
      // TODO(wjwwood): Check ret code.
 | 
					      rmw_ret_t status = rmw_destroy_guard_condition(interrupt_guard_condition_);
 | 
				
			||||||
      rmw_destroy_guard_condition(interrupt_guard_condition_);
 | 
					      if (status != RMW_RET_OK) {
 | 
				
			||||||
 | 
					        fprintf(stderr,
 | 
				
			||||||
 | 
					          "[rclcpp::error] failed to destroy guard condition: %s\n", rmw_get_error_string_safe());
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -121,7 +121,11 @@ public:
 | 
				
			||||||
      if (!rclcpp::utilities::ok()) {
 | 
					      if (!rclcpp::utilities::ok()) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      rmw_trigger_guard_condition(guard_condition_);
 | 
					      rmw_ret_t status = rmw_trigger_guard_condition(guard_condition_);
 | 
				
			||||||
 | 
					      if (status != RMW_RET_OK) {
 | 
				
			||||||
 | 
					        fprintf(stderr,
 | 
				
			||||||
 | 
					          "[rclcpp::error] failed to trigger guard condition: %s\n", rmw_get_error_string_safe());
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -79,7 +79,11 @@ signal_handler(int signal_value)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
  g_signal_status = signal_value;
 | 
					  g_signal_status = signal_value;
 | 
				
			||||||
  rmw_trigger_guard_condition(g_sigint_guard_cond_handle);
 | 
					  rmw_ret_t status = rmw_trigger_guard_condition(g_sigint_guard_cond_handle);
 | 
				
			||||||
 | 
					  if (status != RMW_RET_OK) {
 | 
				
			||||||
 | 
					    fprintf(stderr,
 | 
				
			||||||
 | 
					      "[rclcpp::error] failed to trigger guard condition: %s\n", rmw_get_error_string_safe());
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  g_interrupt_condition_variable.notify_all();
 | 
					  g_interrupt_condition_variable.notify_all();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
} // namespace
 | 
					} // namespace
 | 
				
			||||||
| 
						 | 
					@ -97,8 +101,13 @@ init(int argc, char * argv[])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  (void)argc;
 | 
					  (void)argc;
 | 
				
			||||||
  (void)argv;
 | 
					  (void)argv;
 | 
				
			||||||
  // TODO(wjwwood): Handle rmw_ret_t's value.
 | 
					  rmw_ret_t status = rmw_init();
 | 
				
			||||||
  rmw_init();
 | 
					  if (status != RMW_RET_OK) {
 | 
				
			||||||
 | 
					    // *INDENT-OFF* (prevent uncrustify from making unecessary indents here)
 | 
				
			||||||
 | 
					    throw std::runtime_error(
 | 
				
			||||||
 | 
					      std::string("failed to initialize rmw implementation: ") + rmw_get_error_string_safe());
 | 
				
			||||||
 | 
					    // *INDENT-ON*
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
#ifdef HAS_SIGACTION
 | 
					#ifdef HAS_SIGACTION
 | 
				
			||||||
  struct sigaction action;
 | 
					  struct sigaction action;
 | 
				
			||||||
  memset(&action, 0, sizeof(action));
 | 
					  memset(&action, 0, sizeof(action));
 | 
				
			||||||
| 
						 | 
					@ -131,7 +140,11 @@ void
 | 
				
			||||||
shutdown()
 | 
					shutdown()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  g_signal_status = SIGINT;
 | 
					  g_signal_status = SIGINT;
 | 
				
			||||||
  rmw_trigger_guard_condition(g_sigint_guard_cond_handle);
 | 
					  rmw_ret_t status = rmw_trigger_guard_condition(g_sigint_guard_cond_handle);
 | 
				
			||||||
 | 
					  if (status != RMW_RET_OK) {
 | 
				
			||||||
 | 
					    fprintf(stderr,
 | 
				
			||||||
 | 
					      "[rclcpp::error] failed to trigger guard condition: %s\n", rmw_get_error_string_safe());
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  g_interrupt_condition_variable.notify_all();
 | 
					  g_interrupt_condition_variable.notify_all();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue