X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fmanager.c;h=58848356ea9aec577068650514cfe5b4df30b766;hp=9667e299f3f299faa195c4443c98af9eb442a6f4;hb=ad780f1991d81c8013cc345488b9a035bf30aae7;hpb=f057408c9c3b54b6eeb96cd9f0a1333f30610614 diff --git a/src/manager.c b/src/manager.c index 9667e299f..58848356e 100644 --- a/src/manager.c +++ b/src/manager.c @@ -544,6 +544,12 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) { manager_build_unit_path_cache(m); + /* If we will deserialize make sure that during enumeration + * this is already known, so we increase the counter here + * already */ + if (serialization) + m->n_deserializing ++; + /* First, enumerate what we can from all config files */ r = manager_enumerate(m); @@ -556,6 +562,11 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) { if ((q = manager_coldplug(m)) < 0) r = q; + if (serialization) { + assert(m->n_deserializing > 0); + m->n_deserializing --; + } + /* Now that the initial devices are available, let's see if we * can write the utmp file */ manager_write_utmp_reboot(m); @@ -1317,7 +1328,8 @@ static int transaction_add_job_and_dependencies( assert(type < _JOB_TYPE_MAX); assert(unit); - if (unit->meta.load_state != UNIT_LOADED) { + if (type != JOB_STOP && + unit->meta.load_state != UNIT_LOADED) { dbus_set_error(e, BUS_ERROR_LOAD_FAILED, "Unit %s failed to load. See logs for details.", unit->meta.id); return -EINVAL; } @@ -2334,7 +2346,7 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) { log_debug("Deserializing state..."); - m->deserializing = true; + m->n_deserializing ++; for (;;) { Unit *u; @@ -2366,7 +2378,8 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) { r = 0; finish: - m->deserializing = false; + assert(m->n_deserializing > 0); + m->n_deserializing --; return r; } @@ -2402,6 +2415,8 @@ int manager_reload(Manager *m) { if ((q = lookup_paths_init(&m->lookup_paths, m->running_as)) < 0) r = q; + m->n_deserializing ++; + /* First, enumerate what we can from all config files */ if ((q = manager_enumerate(m)) < 0) r = q; @@ -2417,6 +2432,9 @@ int manager_reload(Manager *m) { if ((q = manager_coldplug(m)) < 0) r = q; + assert(m->n_deserializing > 0); + m->n_deserializing ++; + finish: if (f) fclose(f);