-
Notifications
You must be signed in to change notification settings - Fork 417
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
Fix missing notify of conditional variable in OTLP HTTP exporter test #858
Conversation
Codecov Report
@@ Coverage Diff @@
## main #858 +/- ##
==========================================
+ Coverage 95.49% 95.50% +0.02%
==========================================
Files 156 156
Lines 6618 6620 +2
==========================================
+ Hits 6319 6322 +3
+ Misses 299 298 -1
|
} | ||
|
||
cv_got_events.notify_one(); |
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.
why is this needed ? cv.wait_for
is supposed to be unblocked with a timeout. I think this will fail now if the test is modified so that cv.wait_for
has multiple requests to wait for, as now it will be unblocked after a single request?
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.
Timeout in cv.wait_for
is the last resort. cv
should be waked up anytime its checking condition could be changed, so its condition could be re-checked instead of waiting for timing out. notify_one
just tell cv
to recheck so it should not trigger failure behavior?
cc @owent
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.
Does it mean that without notification, the cv
will keep blocked for 2sec (as configured) even though the condition is satisfied early?
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.
Yes, this is the case the PR trying to fix.
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.
Asking because we are using this construct in other places too:
if (cv_got_events.wait_for(lk, std::chrono::milliseconds(1000 * timeOutSec), |
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.
You are right, it is needed in curl_http_test.cc as well. Added the change to the PR and avoid another 2 timeout to happen there. Thanks for the catch.
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.
Timeout in
cv.wait_for
is the last resort.cv
should be waked up anytime its checking condition could be changed, so its condition could be re-checked instead of waiting for timing out.notify_one
just tellcv
to recheck so it should not trigger failure behavior?cc @owent
You are right. LGTM.
Could you please remove the |
Sure, just removed that. |
Fixes #857
Changes
Added
notify_one
call tocv_got_events
right after HTTP response processing.For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes