manager.h revision 9a0549093332880df47c4218209ce126b8586835
3802a3d3d7af51ddff31943d5514382f01265770Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek This file is part of systemd.
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek Copyright 2010 Lennart Poettering
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek under the terms of the GNU Lesser General Public License as published by
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek the Free Software Foundation; either version 2.1 of the License, or
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek (at your option) any later version.
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek WITHOUT ANY WARRANTY; without even the implied warranty of
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek Lesser General Public License for more details.
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek You should have received a copy of the GNU Lesser General Public License
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek along with systemd; If not, see <http://www.gnu.org/licenses/>.
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek/* Enforce upper limit how many names we allow */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek#define MANAGER_MAX_NAMES 131072 /* 128K */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek /* Note that the set of units we know of is allowed to be
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek * inconsistent. However the subset of it that is loaded may
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek * not, and the list of jobs may neither. */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek /* Active jobs and units */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek Hashmap *units; /* name string => Unit object n:1 */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek Hashmap *jobs; /* job id => Job object 1:1 */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek /* To make it easy to iterate through the units of a specific
8d0e0ddda6501479eb69164687c83c1a7667b33aJan Engelhardt * type we maintain a per type linked list */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek LIST_HEAD(Unit, units_by_type[_UNIT_TYPE_MAX]);
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek /* Units that need to be loaded */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek LIST_HEAD(Unit, load_queue); /* this is actually more a stack than a queue, but uh. */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek /* Jobs that need to be run */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek LIST_HEAD(Job, run_queue); /* more a stack than a queue, too */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek /* Units and jobs that have not yet been announced via
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek * D-Bus. When something about a job changes it is added here
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek * if it is not in there yet. This allows easy coalescing of
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek * D-Bus change signals. */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek LIST_HEAD(Unit, dbus_unit_queue);
8c9571d0ae50656f730a5e37378d5c3dcf3b9789Lennart Poettering /* Units to remove */
8c9571d0ae50656f730a5e37378d5c3dcf3b9789Lennart Poettering /* Units to check when doing GC */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek /* Units that should be realized */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek /* We use two hash tables here, since the same PID might be
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek * watched by two different units: once the unit that forked
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek * it off, and possibly a different unit to which it was
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek * joined as cgroup member. Since we know that it is either
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek * one or two units for each PID we just use to hashmaps
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek Hashmap *watch_pids1; /* pid => Unit object n:1 */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek Hashmap *watch_pids2; /* pid => Unit object n:1 */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek /* A set contains all units which cgroup should be refreshed after startup */
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek /* A set which contains all currently failed units */
0dc5d23c85db85f96b141d4d32deee8018e56a6aLennart Poettering sd_event_source *time_change_event_source;
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek dual_timestamp loader_timestamp;
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek dual_timestamp kernel_timestamp;
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek dual_timestamp initrd_timestamp;
3cc765d2718ac9b4ff978044ceabf5ad59d73edfZbigniew Jędrzejewski-Szmek dual_timestamp userspace_timestamp;
char *generator_unit_path;
char *generator_unit_path_early;
char *generator_unit_path_late;
int private_listen_fd;
char **deserialized_subscribed;
bool send_reloading_done;
int dev_autofs_fd;
char *cgroup_root;
int gc_marker;
unsigned n_in_gc_queue;
int pin_cgroupfs_fd;
bool confirm_spawn;
bool no_console_output;
unsigned default_start_limit_burst;
bool default_cpu_accounting;
int n_reloading;
unsigned n_installed_jobs;
unsigned n_failed_jobs;
unsigned n_running_jobs;
unsigned n_on_console;
unsigned jobs_in_progress_iteration;
char *switch_root;
char *switch_root_init;
int kdbus_fd;
int manager_load_unit_prepare(Manager *m, const char *name, const char *path, sd_bus_error *e, Unit **_ret);
int manager_load_unit(Manager *m, const char *name, const char *path, sd_bus_error *e, Unit **_ret);
int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool force, sd_bus_error *e, Job **_ret);
int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode mode, bool force, sd_bus_error *e, Job **_ret);
void manager_dispatch_bus_name_owner_changed(Manager *m, const char *name, const char* old_owner, const char *new_owner);