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
|
| response_status = 200; | ||
| } | ||
|
|
||
| cv_got_events.notify_one(); |
There was a problem hiding this comment.
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.
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.
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.
Yes, this is the case the PR trying to fix.
There was a problem hiding this comment.
Asking because we are using this construct in other places too:
, probably they need a change too ( in separate PR ).There was a problem hiding this comment.
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.
Timeout in
cv.wait_foris the last resort.cvshould be waked up anytime its checking condition could be changed, so its condition could be re-checked instead of waiting for timing out.notify_onejust tellcvto 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_onecall tocv_got_eventsright after HTTP response processing.For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes