From cdc8f0179fc0d77b460180e385efc13b5b148929 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Tue, 26 Mar 2019 16:19:48 +0100 Subject: [PATCH] Fixed sync bug in HTTP trigger handler --- lib/downloader.cpp | 4 ++-- lib/triggers.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/downloader.cpp b/lib/downloader.cpp index c45ed90f..c20655f4 100644 --- a/lib/downloader.cpp +++ b/lib/downloader.cpp @@ -200,8 +200,8 @@ namespace HTTP{ MEDIUM_MSG("Posting to %s (%zu/%" PRIu32 ")", link.getUrl().c_str(), retryCount - loop + 1, retryCount); doRequest(link, "POST", payload); - // Not synced? Ignore the response and immediately return false. - if (!sync){return false;} + // Not synced? Ignore the response and immediately return true. + if (!sync){return true;} uint64_t reqTime = Util::bootSecs(); while (getSocket() && Util::bootSecs() < reqTime + dataTimeout){ // No data? Wait for a second or so. diff --git a/lib/triggers.cpp b/lib/triggers.cpp index 56706d3c..3198cd7d 100644 --- a/lib/triggers.cpp +++ b/lib/triggers.cpp @@ -54,7 +54,7 @@ namespace Triggers{ DL.setHeader("X-Trigger", trigger); DL.setHeader("Content-Type", "text/plain"); HTTP::URL url(value); - if (DL.post(url, payload, sync) && sync && DL.isOk()){ + if (DL.post(url, payload, sync) && (!sync || DL.isOk())){ submitTriggerStat(trigger, tStartMs, true); return DL.data(); }