Commit 7527cb52 authored by Michal Schmidt's avatar Michal Schmidt
Browse files

manager: Transaction as an object

This makes it obvious that transactions are short-lived. They are created in
manager_add_job() and destroyed after the application of jobs.
It also prepares for a split of the transaction code to a new source.
parent 97e7d748
......@@ -97,7 +97,7 @@ void job_free(Job *j) {
free(j);
}
JobDependency* job_dependency_new(Job *subject, Job *object, bool matters, bool conflicts) {
JobDependency* job_dependency_new(Job *subject, Job *object, bool matters, bool conflicts, Transaction *tr) {
JobDependency *l;
assert(object);
......@@ -118,20 +118,20 @@ JobDependency* job_dependency_new(Job *subject, Job *object, bool matters, bool
if (subject)
LIST_PREPEND(JobDependency, subject, subject->subject_list, l);
else
LIST_PREPEND(JobDependency, subject, object->manager->transaction_anchor, l);
LIST_PREPEND(JobDependency, subject, tr->anchor, l);
LIST_PREPEND(JobDependency, object, object->object_list, l);
return l;
}
void job_dependency_free(JobDependency *l) {
void job_dependency_free(JobDependency *l, Transaction *tr) {
assert(l);
if (l->subject)
LIST_REMOVE(JobDependency, subject, l->subject->subject_list, l);
else
LIST_REMOVE(JobDependency, subject, l->object->manager->transaction_anchor, l);
LIST_REMOVE(JobDependency, subject, tr->anchor, l);
LIST_REMOVE(JobDependency, object, l->object->object_list, l);
......
......@@ -141,8 +141,8 @@ void job_uninstall(Job *j);
void job_free(Job *job);
void job_dump(Job *j, FILE*f, const char *prefix);
JobDependency* job_dependency_new(Job *subject, Job *object, bool matters, bool conflicts);
void job_dependency_free(JobDependency *l);
JobDependency* job_dependency_new(Job *subject, Job *object, bool matters, bool conflicts, Transaction *tr);
void job_dependency_free(JobDependency *l, Transaction *tr);
bool job_is_anchor(Job *j);
......
This diff is collapsed.
......@@ -33,6 +33,7 @@
#define MANAGER_MAX_NAMES 131072 /* 128K */
typedef struct Manager Manager;
typedef struct Transaction Transaction;
typedef enum WatchType WatchType;
typedef struct Watch Watch;
......@@ -91,6 +92,12 @@ struct Watch {
#include "dbus.h"
#include "path-lookup.h"
struct Transaction {
/* Jobs to be added */
Hashmap *jobs; /* Unit object => Job object list 1:1 */
JobDependency *anchor;
};
struct Manager {
/* Note that the set of units we know of is allowed to be
* inconsistent. However the subset of it that is loaded may
......@@ -123,10 +130,6 @@ struct Manager {
/* Units to check when doing GC */
LIST_HEAD(Unit, gc_queue);
/* Jobs to be added */
Hashmap *transaction_jobs; /* Unit object => Job object list 1:1 */
JobDependency *transaction_anchor;
Hashmap *watch_pids; /* pid => Unit object n:1 */
char *notify_socket;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment