#include "virt.h"
#include "watchdog.h"
#include "cgroup-util.h"
+#include "path-util.h"
/* As soon as 16 units are in our GC queue, make sure to run a gc sweep */
#define GC_QUEUE_ENTRIES_MAX 16
m->name_data_slot = m->conn_data_slot = m->subscribed_data_slot = -1;
m->exit_code = _MANAGER_EXIT_CODE_INVALID;
m->pin_cgroupfs_fd = -1;
+ m->idle_pipe[0] = m->idle_pipe[1] = -1;
#ifdef HAVE_AUDIT
m->audit_fd = -1;
hashmap_free(m->cgroup_bondings);
set_free_free(m->unit_path_cache);
+ close_pipe(m->idle_pipe);
+
+ free(m->switch_root);
+ free(m->switch_root_init);
+
free(m);
}
log_debug("Trying to enqueue job %s/%s/%s", unit->id, job_type_to_string(type), job_mode_to_string(mode));
+ job_type_collapse(&type, unit);
+
tr = transaction_new();
if (!tr)
return -ENOMEM;
}
if (!name)
- name = file_name_from_path(path);
+ name = path_get_file_name(path);
t = unit_name_to_type(name);
assert(m);
while ((j = hashmap_first(m->jobs)))
- job_finish_and_invalidate(j, JOB_CANCELED);
+ /* No need to recurse. We're cancelling all jobs. */
+ job_finish_and_invalidate(j, JOB_CANCELED, false);
}
unsigned manager_dispatch_run_queue(Manager *m) {
return m->exit_code;
}
-int manager_get_unit_from_dbus_path(Manager *m, const char *s, Unit **_u) {
+int manager_load_unit_from_dbus_path(Manager *m, const char *s, DBusError *e, Unit **_u) {
char *n;
Unit *u;
+ int r;
assert(m);
assert(s);
if (!startswith(s, "/org/freedesktop/systemd1/unit/"))
return -EINVAL;
- if (!(n = bus_path_unescape(s+31)))
+ n = bus_path_unescape(s+31);
+ if (!n)
return -ENOMEM;
- u = manager_get_unit(m, n);
+ r = manager_load_unit(m, n, NULL, e, &u);
free(n);
- if (!u)
- return -ENOENT;
+ if (r < 0)
+ return r;
*_u = u;
assert(m);
- if (dual_timestamp_is_set(&m->finish_timestamp))
+ if (hashmap_size(m->jobs) > 0)
return;
- if (hashmap_size(m->jobs) > 0)
+ /* Notify Type=idle units that we are done now */
+ close_pipe(m->idle_pipe);
+
+ if (dual_timestamp_is_set(&m->finish_timestamp))
return;
dual_timestamp_get(&m->finish_timestamp);