Function rcl_node_is_valid

Function Documentation

bool rcl_node_is_valid(const rcl_node_t *node)

Return true if the node is valid, else false.

Also return false if the node pointer is NULL or the allocator is invalid.

A node is invalid if:

  • the implementation is NULL (rcl_node_init not called or failed)

  • rcl_shutdown has been called since the node has been initialized

  • the node has been finalized with rcl_node_fini

There is a possible validity race condition.

Consider:

assert(rcl_node_is_valid(node));  // <-- thread 1
rcl_shutdown();                   // <-- thread 2
// use node as if valid           // <-- thread 1

In the third line the node is now invalid, even though on the previous line of thread 1 it was checked to be valid. This is why this function is considered not thread-safe.

Attribute

Adherence

Allocates Memory

No

Thread-Safe

No

Uses Atomics

Yes

Lock-Free

Yes [1]

[1] if returns true for

Parameters:

node[in] rcl_node_t to be validated

Returns:

true if the node and allocator are valid, otherwise false.