assert(m);
+ /* Unset previous data, in case we are called on reload */
+ strv_free(m->unit_path);
+ strv_free(m->sysvinit_path);
+ strv_free(m->sysvrcnd_path);
+ m->unit_path = m->sysvinit_path = m->sysvrcnd_path = NULL;
+
/* First priority is whatever has been passed to us via env
* vars */
if ((e = getenv("SYSTEMD_UNIT_PATH")))
while ((u = hashmap_first(m->units)))
unit_free(u);
+
+ manager_dispatch_cleanup_queue(m);
+
+ assert(!m->load_queue);
+ assert(!m->run_queue);
+ assert(!m->dbus_unit_queue);
+ assert(!m->dbus_job_queue);
+ assert(!m->cleanup_queue);
+ assert(!m->gc_queue);
+
+ assert(hashmap_isempty(m->transaction_jobs));
+ assert(hashmap_isempty(m->jobs));
+ assert(hashmap_isempty(m->units));
}
void manager_free(Manager *m) {
assert(m);
- manager_dispatch_cleanup_queue(m);
manager_clear_jobs_and_units(m);
for (c = 0; c < _UNIT_TYPE_MAX; c++)
break;
}
- case SIGUSR2:
- manager_dump_units(m, stdout, "\t");
- manager_dump_jobs(m, stdout, "\t");
+ case SIGUSR2: {
+ FILE *f;
+ char *dump = NULL;
+ size_t size;
+
+ if (!(f = open_memstream(&dump, &size))) {
+ log_warning("Failed to allocate memory stream.");
+ break;
+ }
+
+ manager_dump_units(m, f, "\t");
+ manager_dump_jobs(m, f, "\t");
+
+ if (ferror(f)) {
+ fclose(f);
+ free(dump);
+ log_warning("Failed to write status stream");
+ break;
+ }
+
+ fclose(f);
+ log_dump(LOG_INFO, dump);
+ free(dump);
+
break;
+ }
case SIGHUP:
m->exit_code = MANAGER_RELOAD;
/* From here on there is no way back. */
manager_clear_jobs_and_units(m);
+ /* Find new unit paths */
+ if ((q = manager_find_paths(m)) < 0)
+ r = q;
+
/* First, enumerate what we can from all config files */
if ((q = manager_enumerate(m)) < 0)
r = q;