X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Funit.c;h=7daf170e29416245046c299f77d2ef99503259c2;hp=88cddbd02355b2c0e3bc4d7a9ba328060b3d4cc1;hb=dab5bf859900c0abdbf78c584e4aed42a19768cd;hpb=e2cc6eca73cd1df8be552d7c23f9ff3d69c06f1e diff --git a/src/core/unit.c b/src/core/unit.c index 88cddbd02..7daf170e2 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -92,6 +92,7 @@ Unit *unit_new(Manager *m, size_t size) { u->deserialized_job = _JOB_TYPE_INVALID; u->default_dependencies = true; u->unit_file_state = _UNIT_FILE_STATE_INVALID; + u->unit_file_preset = -1; u->on_failure_job_mode = JOB_REPLACE; return u; @@ -1726,7 +1727,7 @@ void unit_start_on_failure(Unit *u) { r = manager_add_job(u->manager, JOB_START, other, u->on_failure_job_mode, true, NULL, NULL); if (r < 0) - log_unit_error(u->id, "Failed to enqueue OnFailure= job: %s", strerror(-r)); + log_unit_error_errno(u->id, r, "Failed to enqueue OnFailure= job: %m"); } } @@ -3090,6 +3091,17 @@ UnitFileState unit_get_unit_file_state(Unit *u) { return u->unit_file_state; } +int unit_get_unit_file_preset(Unit *u) { + assert(u); + + if (u->unit_file_preset < 0 && u->fragment_path) + u->unit_file_preset = unit_file_query_preset( + u->manager->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, + NULL, basename(u->fragment_path)); + + return u->unit_file_preset; +} + Unit* unit_ref_set(UnitRef *ref, Unit *u) { assert(ref); assert(u); @@ -3435,7 +3447,7 @@ int unit_kill_context( _cleanup_free_ char *comm = NULL; get_process_comm(main_pid, &comm); - log_unit_warning(u->id, "Failed to kill main process " PID_FMT " (%s): %s", main_pid, strna(comm), strerror(-r)); + log_unit_warning_errno(u->id, r, "Failed to kill main process " PID_FMT " (%s): %m", main_pid, strna(comm)); } else { if (!main_pid_alien) wait_for_exit = true; @@ -3452,7 +3464,7 @@ int unit_kill_context( _cleanup_free_ char *comm = NULL; get_process_comm(control_pid, &comm); - log_unit_warning(u->id, "Failed to kill control process " PID_FMT " (%s): %s", control_pid, strna(comm), strerror(-r)); + log_unit_warning_errno(u->id, r, "Failed to kill control process " PID_FMT " (%s): %m", control_pid, strna(comm)); } else { wait_for_exit = true; @@ -3472,7 +3484,7 @@ int unit_kill_context( r = cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, sig, true, true, false, pid_set); if (r < 0) { if (r != -EAGAIN && r != -ESRCH && r != -ENOENT) - log_unit_warning(u->id, "Failed to kill control group: %s", strerror(-r)); + log_unit_warning_errno(u->id, r, "Failed to kill control group: %m"); } else if (r > 0) { /* FIXME: For now, we will not wait for the