From: Michal Sekletar Date: Tue, 30 May 2023 13:47:16 +0000 (+0200) Subject: core/transaction: drop job that has unfulfilled required (Requires, BindsTo) dependencies X-Git-Tag: v254-rc1~319 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=89e9df12b3850800780693a1c746716c655d77ef;p=thirdparty%2Fsystemd.git core/transaction: drop job that has unfulfilled required (Requires, BindsTo) dependencies Resolves: #11338 --- diff --git a/src/core/transaction.c b/src/core/transaction.c index 65a00bd9284..39f8f6c96df 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -1003,7 +1003,7 @@ int transaction_add_job_and_dependencies( r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, false, false, ignore_order, e); if (r < 0) { if (r != -EBADR) /* job type not applicable */ - return r; + goto fail; sd_bus_error_free(e); } @@ -1025,7 +1025,7 @@ int transaction_add_job_and_dependencies( r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, true, false, false, ignore_order, e); if (r < 0) { if (r != -EBADR) /* job type not applicable */ - return r; + goto fail; sd_bus_error_free(e); } @@ -1035,7 +1035,7 @@ int transaction_add_job_and_dependencies( r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, true, true, false, ignore_order, e); if (r < 0) { if (r != -EBADR) /* job type not applicable */ - return r; + goto fail; sd_bus_error_free(e); } @@ -1102,6 +1102,13 @@ int transaction_add_job_and_dependencies( } return 0; +fail: + /* Recursive call failed to add required jobs so let's drop top level job as well. */ + log_unit_debug_errno(unit, r, "Cannot add dependency job to transaction, deleting job %s/%s again: %s", + unit->id, job_type_to_string(type), bus_error_message(e, r)); + transaction_delete_job(tr, ret, /* delete_dependencies= */ false); + return r; + } static bool shall_stop_on_isolate(Transaction *tr, Unit *u) {