| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include "core-forward.h" |
| 5 |
|
| 6 |
typedef struct Transaction { |
| 7 |
/* Jobs to be added */ |
| 8 |
Hashmap *jobs; /* Unit object => Job object list 1:1 */ |
| 9 |
Job *anchor_job; /* The job the user asked for */ |
| 10 |
bool irreversible; |
| 11 |
|
| 12 |
uint64_t id; |
| 13 |
} Transaction; |
| 14 |
|
| 15 |
Transaction* transaction_new(bool irreversible, uint64_t id); |
| 16 |
Transaction* transaction_free(Transaction *tr); |
| 17 |
Transaction* transaction_abort_and_free(Transaction *tr); |
| 18 |
DEFINE_TRIVIAL_CLEANUP_FUNC(Transaction*, transaction_abort_and_free); |
| 19 |
|
| 20 |
typedef enum TransactionAddFlags { |
| 21 |
TRANSACTION_MATTERS = 1 << 0, |
| 22 |
TRANSACTION_CONFLICTS = 1 << 1, |
| 23 |
TRANSACTION_IGNORE_REQUIREMENTS = 1 << 2, |
| 24 |
TRANSACTION_IGNORE_ORDER = 1 << 3, |
| 25 |
|
| 26 |
/* Propagate a START job to other units like a RESTART */ |
| 27 |
TRANSACTION_PROPAGATE_START_AS_RESTART = 1 << 4, |
| 28 |
|
| 29 |
/* Indicate that we're in the recursion for processing UNIT_ATOM_PROPAGATE_STOP_GRACEFUL units */ |
| 30 |
TRANSACTION_PROCESS_PROPAGATE_STOP_GRACEFUL = 1 << 5, |
| 31 |
|
| 32 |
/* Always re-enqueue anchor job (refuse late merge) */ |
| 33 |
TRANSACTION_REENQUEUE_ANCHOR = 1 << 6, |
| 34 |
|
| 35 |
_TRANSACTION_FLAGS_MASK_PUBLIC = TRANSACTION_REENQUEUE_ANCHOR, |
| 36 |
} TransactionAddFlags; |
| 37 |
|
| 38 |
void transaction_add_propagate_reload_jobs( |
| 39 |
Transaction *tr, |
| 40 |
Unit *unit, |
| 41 |
Job *by, |
| 42 |
TransactionAddFlags flags); |
| 43 |
|
| 44 |
int transaction_add_isolate_jobs(Transaction *tr, Manager *m); |
| 45 |
int transaction_add_triggering_jobs(Transaction *tr, Unit *u); |
| 46 |
|
| 47 |
int transaction_add_job_and_dependencies( |
| 48 |
Transaction *tr, |
| 49 |
JobType type, |
| 50 |
Unit *unit, |
| 51 |
Job *by, |
| 52 |
TransactionAddFlags flags, |
| 53 |
sd_bus_error *e); |
| 54 |
|
| 55 |
int transaction_activate(Transaction *tr, Manager *m, JobMode mode, Set *affected, sd_bus_error *e); |