From 8f3f943fa5c5c812e29df63ef1bb06a70fe5b070 Mon Sep 17 00:00:00 2001 From: David Bondy Date: Mon, 2 Oct 2023 20:49:00 -0600 Subject: [PATCH] Revert "DOn't set the timeout in poll to zero" --- BedrockServer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/BedrockServer.cpp b/BedrockServer.cpp index 94b5026f9..45f8cf5fe 100644 --- a/BedrockServer.cpp +++ b/BedrockServer.cpp @@ -820,20 +820,21 @@ void BedrockServer::runCommand(unique_ptr&& _command, bool isBlo networkLoopCount++; fd_map fdm; command->prePoll(fdm); + const uint64_t now = STimeNow(); + uint64_t nextActivity = 0; + S_poll(fdm, max(nextActivity, now) - now); // Timeout is five minutes unless we're shutting down or standing down, in which case it's 5 seconds. // Note that BedrockCommad::postPoll sets the timeout to the command's timeout if it's lower than this value anyway, // So this only has an effect if it will be shorter than the command's timeout. - uint64_t maxWaitUs = 5 * 60 * 1'000'000; + uint64_t maxWaitMs = 5 * 60 * 1'000; auto _syncNodeCopy = atomic_load(&_syncNode); if (_shutdownState.load() != RUNNING || (_syncNodeCopy && _syncNodeCopy->getState() == SQLiteNodeState::STANDINGDOWN)) { - maxWaitUs = 5'000'000; + maxWaitMs = 5'000; } - S_poll(fdm, maxWaitUs); - auto start = STimeNow(); - command->postPoll(fdm, maxWaitUs, maxWaitUs); + command->postPoll(fdm, nextActivity, maxWaitMs); postPollCumulativeTime += (STimeNow() - start); }