Files
systemd/src/core/transaction.h
T
Luca BoccassiandMichal Koutný 7d3b32daef core: add method to enqueue multiple jobs in a single call
Currently only a single job for a single unit can be enqueued atomically,
so there is no guarantee that, e.g., starting a unit and its socket
at the same time will happen in the same transaction. That forces
callers to 'know' the right order in which to start new units being
installed, or failures will occur. It also means some ordering
constraints are ignored, in case the separate calls are done
in the wrong manual order.

Add a new EnqueueUnitJobMany() D-Bus method that takes a list of units
to start.

Fixes https://github.com/systemd/systemd/issues/8102

Co-authored-by: Michal Koutný <mkoutny@suse.com>
2026-06-22 13:01:17 +01:00

56 lines
2.0 KiB
C

/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "core-forward.h"
typedef struct Transaction {
/* Jobs to be added */
Hashmap *jobs; /* Unit object => Job object list 1:1 */
Set *anchor_jobs; /* the jobs the user asked for */
bool irreversible;
uint64_t id;
} Transaction;
Transaction* transaction_new(bool irreversible, uint64_t id);
Transaction* transaction_free(Transaction *tr);
Transaction* transaction_abort_and_free(Transaction *tr);
DEFINE_TRIVIAL_CLEANUP_FUNC(Transaction*, transaction_abort_and_free);
typedef enum TransactionAddFlags {
TRANSACTION_MATTERS = 1 << 0,
TRANSACTION_CONFLICTS = 1 << 1,
TRANSACTION_IGNORE_REQUIREMENTS = 1 << 2,
TRANSACTION_IGNORE_ORDER = 1 << 3,
/* Propagate a START job to other units like a RESTART */
TRANSACTION_PROPAGATE_START_AS_RESTART = 1 << 4,
/* Indicate that we're in the recursion for processing UNIT_ATOM_PROPAGATE_STOP_GRACEFUL units */
TRANSACTION_PROCESS_PROPAGATE_STOP_GRACEFUL = 1 << 5,
/* Always re-enqueue anchor job (refuse late merge) */
TRANSACTION_REENQUEUE_ANCHOR = 1 << 6,
_TRANSACTION_FLAGS_MASK_PUBLIC = TRANSACTION_REENQUEUE_ANCHOR,
} TransactionAddFlags;
void transaction_add_propagate_reload_jobs(
Transaction *tr,
Unit *unit,
Job *by,
TransactionAddFlags flags);
int transaction_add_isolate_jobs(Transaction *tr, Manager *m);
int transaction_add_triggering_jobs(Transaction *tr, Unit *u);
int transaction_add_job_and_dependencies(
Transaction *tr,
JobType type,
Unit *unit,
Job *by,
TransactionAddFlags flags,
sd_bus_error *e);
int transaction_activate(Transaction *tr, Manager *m, JobMode mode, Set *affected, sd_bus_error *e);