]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
varlink: didn't generate a varlink error reply if a failed method call handler alread...
authorLennart Poettering <lennart@poettering.net>
Wed, 11 Oct 2023 14:59:59 +0000 (16:59 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 11 Oct 2023 16:19:36 +0000 (18:19 +0200)
It might happen that a method call handler already generated an error
reply and then still propagated the error back to the varlink logic.
Let's not try to generate a 2nd reply from that error code then, but
simply proceed without. This simplifies handling of errors in method
call handlers, because they can uniformly return errno-style error
codes, and only if they want return a full Varlink errror.

src/shared/varlink.c

index 8f643e27b0fd152ff71381a1fdee58608d2b5b59..118ede7e05d6194c3bb21beb3319ae0f69e1899e 100644 (file)
@@ -1330,7 +1330,9 @@ static int varlink_dispatch_method(Varlink *v) {
                                 log_debug_errno(r, "Callback for %s returned error: %m", method);
 
                                 /* We got an error back from the callback. Propagate it to the client if the method call remains unanswered. */
-                                if (!FLAGS_SET(flags, VARLINK_METHOD_ONEWAY)) {
+                                if (v->state == VARLINK_PROCESSED_METHOD)
+                                        r = 0; /* already processed */
+                                else if (!FLAGS_SET(flags, VARLINK_METHOD_ONEWAY)) {
                                         r = varlink_error_errno(v, r);
                                         if (r < 0)
                                                 return r;