mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-24 02:13:02 -07:00
[DeckStorage] Keep the visibility refresh armed until replies land
The single-shot drain was armed with the 500 ms delay at send time, so a round trip slower than that drained before the server applied the change, re-read the old state and never re-armed, leaving the column stale until a manual refresh. The timer is now armed with the full network timeout at send time (a lost reply still costs one stale refresh) and re-armed with the short delay every time a reply lands.
This commit is contained in:
parent
dd2400d245
commit
e0f8fd0091
1 changed files with 15 additions and 4 deletions
|
|
@ -127,10 +127,11 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor,
|
||||||
SettingsCache::instance().network().getKeepAlive() * 1000));
|
SettingsCache::instance().network().getKeepAlive() * 1000));
|
||||||
connect(shareTimeoutTimer, &QTimer::timeout, this, &TabDeckStorage::onShareFromTreeTimeout);
|
connect(shareTimeoutTimer, &QTimer::timeout, this, &TabDeckStorage::onShareFromTreeTimeout);
|
||||||
|
|
||||||
// Restartable single-shot refresh for the Public/Private column. A dropped
|
// Restartable single-shot refresh for the Public/Private column. It is
|
||||||
// visibility reply must not leave the widget permanently stale, so the tree
|
// armed with the full network timeout when a publish is sent (so a dropped
|
||||||
// is re-read whenever publishes quiet down instead of waiting on a count
|
// reply still drains once) and re-armed with the short delay every time a
|
||||||
// that can get stuck above zero.
|
// reply lands, so the drain cannot fire while a slow round trip is still in
|
||||||
|
// flight. Either way the tree is re-read once things quiet down.
|
||||||
visibilityRefreshTimer = new QTimer(this);
|
visibilityRefreshTimer = new QTimer(this);
|
||||||
visibilityRefreshTimer->setSingleShot(true);
|
visibilityRefreshTimer->setSingleShot(true);
|
||||||
visibilityRefreshTimer->setInterval(VISIBILITY_REFRESH_DELAY);
|
visibilityRefreshTimer->setInterval(VISIBILITY_REFRESH_DELAY);
|
||||||
|
|
@ -862,6 +863,13 @@ void TabDeckStorage::onShareFromTreeTimeout()
|
||||||
void TabDeckStorage::actPublishDeck()
|
void TabDeckStorage::actPublishDeck()
|
||||||
{
|
{
|
||||||
visibilityFailures.clear();
|
visibilityFailures.clear();
|
||||||
|
// Arm the drain with the full network timeout so a lost reply still costs
|
||||||
|
// one refresh instead of a dead column; each reply shrinks it to the short
|
||||||
|
// delay below, so a slow round trip is never drained before it lands.
|
||||||
|
const int visibilityFailSafeDelay =
|
||||||
|
static_cast<int>((static_cast<qint64>(SettingsCache::instance().network().getTimeOut()) + 1) *
|
||||||
|
SettingsCache::instance().network().getKeepAlive() * 1000);
|
||||||
|
|
||||||
const auto selection = serverDirView->getCurrentSelection();
|
const auto selection = serverDirView->getCurrentSelection();
|
||||||
for (const auto *node : selection) {
|
for (const auto *node : selection) {
|
||||||
Command_DeckSetVisibility cmd;
|
Command_DeckSetVisibility cmd;
|
||||||
|
|
@ -884,6 +892,7 @@ void TabDeckStorage::actPublishDeck()
|
||||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||||
connect(pend, &PendingCommand::finished, this, &TabDeckStorage::setVisibilityFinished);
|
connect(pend, &PendingCommand::finished, this, &TabDeckStorage::setVisibilityFinished);
|
||||||
visibilityRefreshStarted = true;
|
visibilityRefreshStarted = true;
|
||||||
|
visibilityRefreshTimer->setInterval(visibilityFailSafeDelay);
|
||||||
visibilityRefreshTimer->start();
|
visibilityRefreshTimer->start();
|
||||||
client->sendCommand(pend);
|
client->sendCommand(pend);
|
||||||
}
|
}
|
||||||
|
|
@ -893,6 +902,7 @@ void TabDeckStorage::setVisibilityFinished(const Response &r, const CommandConta
|
||||||
{
|
{
|
||||||
if (r.response_code() == Response::RespOk) {
|
if (r.response_code() == Response::RespOk) {
|
||||||
if (visibilityRefreshStarted) {
|
if (visibilityRefreshStarted) {
|
||||||
|
visibilityRefreshTimer->setInterval(VISIBILITY_REFRESH_DELAY);
|
||||||
visibilityRefreshTimer->start();
|
visibilityRefreshTimer->start();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -904,6 +914,7 @@ void TabDeckStorage::setVisibilityFinished(const Response &r, const CommandConta
|
||||||
.arg(QString::number(static_cast<int>(r.response_code())));
|
.arg(QString::number(static_cast<int>(r.response_code())));
|
||||||
if (visibilityRefreshStarted) {
|
if (visibilityRefreshStarted) {
|
||||||
visibilityFailures.append(message);
|
visibilityFailures.append(message);
|
||||||
|
visibilityRefreshTimer->setInterval(VISIBILITY_REFRESH_DELAY);
|
||||||
visibilityRefreshTimer->start();
|
visibilityRefreshTimer->start();
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::critical(this, tr("Error"), message);
|
QMessageBox::critical(this, tr("Error"), message);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue