Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EK-30] Fix TOCTTOU race in SingleGoalMultipleActionServers implementation #78

Merged

Conversation

mhidalgo-bdai
Copy link
Contributor

Precisely what the title says. This patch prevents race conditions when enforcing multiple actions managed by a single SingleGoalMultipleActionServers instance are mutually exclusive. It also migrates to cancellation rather than abortion for goal preemption.

Signed-off-by: Michel Hidalgo <[email protected]>
func: typing.Optional[typing.Callable] = None,
lock: typing.Optional[threading.Lock] = None,
) -> typing.Callable:
"""Wraps `func` to synchronize invocations, optionally taking a user defined `lock`."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add to the docstring the use case for func being None?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing. Done in a924c85

Copy link
Collaborator

@amessing-bdai amessing-bdai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on the condition that the docstring is updated

Signed-off-by: Michel Hidalgo <[email protected]>
Signed-off-by: Michel Hidalgo <[email protected]>
@mhidalgo-bdai
Copy link
Contributor Author

Argh, there was a race in the tests. It is fixed now. PTAL !

Signed-off-by: Michel Hidalgo <[email protected]>
@@ -22,25 +23,31 @@ def __init__(
self,
node: Node,
action_server_parameters: List[Tuple[ActionType, str, Callable, Optional[CallbackGroup]]],
nosync: bool = False,
) -> None:
"""Constructor"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the docstring with when you would want to set nosync to True?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 224a408.

@mhidalgo-bdai mhidalgo-bdai merged commit facc8b2 into main Mar 19, 2024
3 checks passed
@mhidalgo-bdai mhidalgo-bdai deleted the mhidalgo-bdai/no-race-single-goal-multiple-action-server branch March 19, 2024 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants