Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions cpp/src/IceGrid/ServerCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,22 +707,13 @@ void
ServerEntry::waitImpl(chrono::seconds timeout)
{
unique_lock lock(_mutex);
if (timeout != 0s)
if (timeout > 0s)
{
while (_synchronizing)
{
if (timeout > 0s)
{
if (_condVar.wait_for(lock, timeout) == cv_status::timeout)
{
break; // Timeout
}
}
else
{
_condVar.wait(lock);
}
}
_condVar.wait_until(lock, chrono::steady_clock::now() + timeout, [this] { return !_synchronizing; });

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The symptom is a late SynchronizationException, and only under sustained allocation churn on the same entry — notifications must keep arriving faster than the timeout to extend the wait. Nothing user-visible changes during normal operations, so no changelog entry.

Comment on lines +710 to +712

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Asserting that the exception lands at the original deadline means a wall-clock timing assertion while generating cross-thread notification churn — that's a flaky test, not a regression guard. The change is the standard deadline-with-predicate idiom; the existing allocation suite covers the functional behavior.

}
else if (timeout < 0s)
{
_condVar.wait(lock, [this] { return !_synchronizing; });
}
if (_synchronizing) // If we are still synchronizing, throw SynchronizationException
Comment on lines 717 to 718

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reaching this if (_synchronizing) is impossible. Can we just replace with an assert?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Couldn't we still hit this when timeout > 0s, and we hit the timeout?
wait_until doesn't throw I don't think. It just returns false (if we hit the timeout).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, you're right I didn't read this very well.

{
Expand Down
Loading