From: Michael Tremer Date: Fri, 10 Jul 2026 11:41:52 +0000 (+0000) Subject: source: Don't log (non-)errors of async tasks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45698f5330ede579a68514d35e97e6c3f96332fc;p=telemetry.git source: Don't log (non-)errors of async tasks We don't want to log the dispatching of a command as "success" if the actual command later won't execute. So we reserve EINPROGRESS that sources can signal that something is running... Signed-off-by: Michael Tremer --- diff --git a/src/daemon/client.c b/src/daemon/client.c index 41fdc33..9b3ee3f 100644 --- a/src/daemon/client.c +++ b/src/daemon/client.c @@ -414,6 +414,9 @@ int td_client_launch_request(td_client* self, td_request* request) { // Let cURL hold a reference to the request object td_request_ref(request); + // Signal that this operation is now in progress + r = -EINPROGRESS; + ERROR: if (url) free(url); diff --git a/src/daemon/command.c b/src/daemon/command.c index 4c426a3..f3e9948 100644 --- a/src/daemon/command.c +++ b/src/daemon/command.c @@ -616,7 +616,8 @@ static int td_command_parent(td_command* self) { } } - return r; + // Signal that some operation is in progress + return -EINPROGRESS; } static int td_command_child(td_command* self, const char** argv) { diff --git a/src/daemon/source.c b/src/daemon/source.c index 6108cfc..3ad5a22 100644 --- a/src/daemon/source.c +++ b/src/daemon/source.c @@ -196,6 +196,18 @@ static int td_source_error_detection(td_source* self, int result, uint64_t runti enum td_source_state state; int r; + // Ignore some return codes + switch (-result) { + // If the heartbeat callback has launched an asynchronous task (e.g. executing + // a command or sending a HTTP request), we will expect this to be signalled + // and won't log any errors right now. + case EINPROGRESS: + return 0; + + default: + break; + } + // Move everything up in the array for (unsigned int i = NUM_RESULTS - 1; i > 0; i--) self->results.r[i] = self->results.r[i - 1]; @@ -304,8 +316,15 @@ static int td_source_heartbeat(sd_event_source* source, uint64_t usec, void* dat // Call the heartbeat method r = self->impl->heartbeat(self->ctx, self); if (r < 0) { - ERROR(self->ctx, "heartbeat() failed for %s: %s\n", - td_source_name(self), strerror(-r)); + switch (-r) { + case EINPROGRESS: + break; + + default: + ERROR(self->ctx, "heartbeat() failed for %s: %s\n", + td_source_name(self), strerror(-r)); + break; + } } // Fetch the end timestamp