0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00

modules/m_vm_fetch: Allow prev_fetch to check if events arrived elsehow while waiting.

This commit is contained in:
Jason Volk 2020-04-16 18:53:29 -07:00
parent 7b0f17368d
commit 6124bf612c

View file

@ -605,12 +605,25 @@ ircd::m::vm::fetch::prev(const event &event,
ctx::when_all(begin(futures), end(futures)) ctx::when_all(begin(futures), end(futures))
}; };
// yields context const auto timeout
const bool done
{ {
fetching.wait(seconds(event_timeout), std::nothrow) now<system_point>() + seconds(event_timeout)
}; };
// Rather than waiting for all of the events to arrive or for the entire
// timeout to expire, we check if the sought events made it to the server
// in the meantime. If so we can drop these requests and bail.
while(now<system_point>() < timeout)
{
// Wait for an interval to give this loop some iterations.
if(fetching.wait(milliseconds(500), std::nothrow))
break;
// Check for satisfaction.
if((prev_exists = prev.prev_events_exist()) == prev_count)
return;
}
// evaluate results // evaluate results
for(auto &future : futures) try for(auto &future : futures) try
{ {