-
Notifications
You must be signed in to change notification settings - Fork 85
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
Bugfix/blocking uxr create session #351
base: develop
Are you sure you want to change the base?
Bugfix/blocking uxr create session #351
Conversation
…cking in uxr_create_session * Added asserts that protect against time going backwards or staying static * Added information to header on a call being blocking and for how long * Increased const-correctecness of time handling * Add assert for handling narrowing conversion of time * Add CMake protection for incorrectly configuring options that can block for unreasonable amount of time * CMake should theoretically remove the asserts in release mode, so there should be no overhead * Reference: https://stackoverflow.com/questions/34302265/does-cmake-build-type-release-imply-dndebug * Closes eProsima#350 Signed-off-by: Ryan Friedman <[email protected]>
I can't see any reason the build is failing. Let me know what I am missing. Searched for errors in the logs, all tests pass. Thanks! Since CI only builds in release mode by default, if you want me to add tests for the new lines of code, the gtest tests will need to be run in debug mode and check for assertion failures when you supply bad time or misconfiguration to that function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is preferred to not use assert()
, could you refactor the logic to avoid it?
int remaining_time = UXR_CONFIG_MIN_SESSION_CONNECTION_INTERVAL; | ||
const int64_t start_timestamp = uxr_millis(); | ||
int64_t remaining_time = UXR_CONFIG_MIN_SESSION_CONNECTION_INTERVAL; | ||
assert(remaining_time > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not using assert in this project's code base, this can lead to portability issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I thought this library was C99 complaint.
Are the users with incompatible C support able to set NDEBUG all the time then?
If not, can you give an example of the desired error propagation method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is preferred to check for the underflow and return false as far as wait_session_status
was not successful
Probably uncrustify is failing, try:
|
Here's my fix to the blocking nature of uxr_create_session.
uxr_millis()
function is not working correctly, or the time source is frozen, stuck at zero, or jumps backwards.This closes #350
In CMakeCache, one can see when
NDEBUG
is set, which would remove the asserts.Since asserts aren't used yet in the library, it would be nice to add some documentation for library implementers to ensure they are disabled in production releases, but can be on during development.