From 1c7bd7d5c4ff7afaecf4a68978ae53e9d2094026 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 28 Dec 2018 14:02:41 +0100 Subject: [PATCH] db/update/InotifyQueue: check for ACK_ERROR_UPDATE_ALREADY Since commit cc64c715a20, UpdateService::Enqueue() throws ProtocolError(ACK_ERROR_UPDATE_ALREADY) instead of returning 0. --- src/db/update/InotifyQueue.cxx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/db/update/InotifyQueue.cxx b/src/db/update/InotifyQueue.cxx index 5dd97690a..84b576b2e 100644 --- a/src/db/update/InotifyQueue.cxx +++ b/src/db/update/InotifyQueue.cxx @@ -21,6 +21,7 @@ #include "InotifyDomain.hxx" #include "Service.hxx" #include "Log.hxx" +#include "protocol/Ack.hxx" // for class ProtocolError #include "util/StringCompare.hxx" /** @@ -40,7 +41,17 @@ InotifyQueue::OnDelay() noexcept const char *uri_utf8 = queue.front().c_str(); try { - id = update.Enqueue(uri_utf8, false); + try { + id = update.Enqueue(uri_utf8, false); + } catch (const ProtocolError &e) { + if (e.GetCode() == ACK_ERROR_UPDATE_ALREADY) { + /* retry later */ + delay_event.Schedule(INOTIFY_UPDATE_DELAY); + return; + } + + throw; + } } catch (...) { FormatError(std::current_exception(), "Failed to enqueue '%s'", uri_utf8); @@ -48,12 +59,6 @@ InotifyQueue::OnDelay() noexcept continue; } - if (id == 0) { - /* retry later */ - delay_event.Schedule(INOTIFY_UPDATE_DELAY); - return; - } - FormatDebug(inotify_domain, "updating '%s' job=%u", uri_utf8, id);