Skip to content

Commit 0fd9d98

Browse files
authored
Fix timeout_ns set value when None is passed to timeout param (#105)
`rcl_wait` requires negative value if procedure wants to block thread indefinitely until some messages are passed. However, in current implementation, `timeout_ns` is set to zero, even if `timeout` param is `None`, and this results in making `rcl_wait` non-blocking function ( returns immediately ). To make it correctly, I fixed to set `timeout_ns` to `-1` if `timeout` param is `None`.
1 parent b209538 commit 0fd9d98

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rclrs/src/wait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl WaitSet {
150150
/// [1]: std::time::Duration::ZERO
151151
pub fn wait(&mut self, timeout: Option<Duration>) -> Result<ReadyEntities, RclReturnCode> {
152152
let timeout_ns = match timeout.map(|d| d.as_nanos()) {
153-
None => 0,
153+
None => -1,
154154
Some(ns) if ns <= i64::MAX as u128 => ns as i64,
155155
_ => {
156156
return Err(RclReturnCode::InvalidArgument);

0 commit comments

Comments
 (0)