summaryrefslogtreecommitdiff
path: root/src/core/transaction.c
Commit message (Collapse)AuthorAge
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-23
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* sd-bus: move common errors src/shared/bus-errors.h → ↵Lennart Poettering2014-12-10
| | | | | | src/libsystemd/sd-bus/bus-common-errors.h Stuff in src/shared/ should not use stuff from src/libsystemd/ really.
* treewide: more log_*_errno + return simplificationsMichal Schmidt2014-11-28
|
* treewide: no need to negate errno for log_*_errno()Michal Schmidt2014-11-28
| | | | It corrrectly handles both positive and negative errno values.
* treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt2014-11-28
| | | | | | | | | | | | | As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
* log: rearrange log function namingLennart Poettering2014-11-27
| | | | | | | | | | - Rename log_meta() → log_internal(), to follow naming scheme of most other log functions that are usually invoked through macros, but never directly. - Rename log_info_object() to log_object_info(), simply because the object should be before any other parameters, to follow OO-style programming style.
* core: fix transaction destructiveness check once moreMichal Schmidt2014-11-27
| | | | | | | | | | | | | | The previous fix e0312f4db "core: fix check for transaction destructiveness" broke test-engine (noticed by Zbyszek). Apparently I had a wrong idea of the intended semantics of --fail. The manpage says the operation should fail if it "conflicts with a pending job (more specifically: causes an already pending start job to be reversed into a stop job or vice versa)". So let's check job_type_is_conflicting, instead of !is_superset. This makes both test-engine and TEST-03-JOBS pass again.
* core: fix check for transaction destructivenessMichal Schmidt2014-11-26
| | | | | | | When checking if the transaction is destructive, we need to check if the previously installed job is a superset of the new job (and hence the new job will fold into the installed one without changing it), not the other way around.
* Raise level of 'Found dependency...' linesZbigniew Jędrzejewski-Szmek2014-11-02
| | | | | | | | | | | | | | | | This way they always show up together with 'Found ordering cycle...'. Ordering cycles are a serious error and a major pain to debug. If quiet is enabled, only the first and the last line of output are shown: systemd[1]: Found ordering cycle on basic.target/start systemd[1]: Breaking ordering cycle by deleting job timers.target/start systemd[1]: Job timers.target/start deleted to break ordering cycle starting with basic.target/start which isn't particularly enlightening. So just show the whole message at the same level. https://bugzilla.redhat.com/show_bug.cgi?id=1158206
* Convert the rest to sd_bus_errnomapZbigniew Jędrzejewski-Szmek2014-10-30
| | | | | | I tried to preserve most errno values, but in some cases they were inconsistent (different errno values for the same error name) or just mismatched.
* hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt2014-09-15
| | | | | | | | | It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory.
* systemd-analyze verify: improve error messageZbigniew Jędrzejewski-Szmek2014-07-31
| | | | There's little sense in telling the user to look at the logs...
* core/transaction: fix cycle break attempts outside transactionUoti Urpala2014-06-26
| | | | | | | | | | | | | | | | | | | Patch fixes some incorrect-looking code in transaction.c. It could fix cases where Debian users with bad package configurations had systemd go into an infinite loop printing messages about breaking an ordering cycle, though I have not reproduced that problem myself. transaction_verify_order_one() considers jobs/units outside current transaction when checking whether ordering dependencies cause cycles. It would also incorrectly try to break cycles at these jobs; this cannot work, as the break action is to remove the job from the transaction, which is a no-op if the job isn't part of the transaction to begin with. The unit_matters_to_anchor() test also looks like it would not work correctly for non-transaction jobs. Add a check to verify that the unit is part of the transaction before considering a job a candidate for deletion. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752259
* core/transaction: avoid misleading error message when unit not foundZbigniew Jędrzejewski-Szmek2014-06-22
| | | | | | | There's no point in telling the user to look at the logs when an attempt to load the unit file failed with ENOENT. https://bugzilla.redhat.com/show_bug.cgi?id=996133
* core/transaction: reindent and split very long linesZbigniew Jędrzejewski-Szmek2014-06-22
|
* transaction: print more information about conflicting jobsZbigniew Jędrzejewski-Szmek2014-02-06
| | | | Also remove some debug statement that should not have been committed.
* core: add new "flush" job mode to cancel all other jobs when queuing a new jobLennart Poettering2013-11-26
|
* core: convert PID 1 to libsystemd-busLennart Poettering2013-11-20
| | | | | | | | | | | | | | | | | | | | | | This patch converts PID 1 to libsystemd-bus and thus drops the dependency on libdbus. The only remaining code using libdbus is a test case that validates our bus marshalling against libdbus' marshalling, and this dependency can be turned off. This patch also adds a couple of things to libsystem-bus, that are necessary to make the port work: - Synthesizing of "Disconnected" messages when bus connections are severed. - Support for attaching multiple vtables for the same interface on the same path. This patch also fixes the SetDefaultTarget() and GetDefaultTarget() bus calls which used an inappropriate signature. As a side effect we will now generate PropertiesChanged messages which carry property contents, rather than just invalidation information.
* list: make our list macros a bit easier to use by not requring type spec on ↵Lennart Poettering2013-10-14
| | | | | | | each invocation We can determine the list entry type via the typeof() gcc construct, and so we should to make the macros much shorter to use.
* transaction.c: do not point users to logs when unit not foundZbigniew Jędrzejewski-Szmek2013-09-16
| | | | | | | | | | | The logs are unlikely to contain any useful information in this case. Also, change "walked on cycle path" to "found dependency on", which is less technical and indicates the direction. With the old message, I was never sure if prior units depended on later ones, or vice versa. https://bugzilla.redhat.com/show_bug.cgi?id=996133 https://bugzilla.redhat.com/show_bug.cgi?id=997082
* systemd: do not output status messages once gettys are runningZbigniew Jędrzejewski-Szmek2013-07-15
| | | | | | | | | | | | | | | | Make Type=idle communication bidirectional: when bootup is finished, the manager, as before, signals idling Type=idle jobs to continue. However, if the boot takes too long, idling jobs signal the manager that they have had enough, wait a tiny bit more, and continue, taking ownership of the console. The manager, when signalled that Type=idle jobs are done, makes a note and will not write to the console anymore. This is a cosmetic issue, but quite noticable, so let's just fix it. Based on Harald Hoyer's patch. https://bugs.freedesktop.org/show_bug.cgi?id=54247 http://unix.stackexchange.com/questions/51805/systemd-messages-after-starting-login/
* core: add transient unitsLennart Poettering2013-06-28
| | | | | | | | | | | | | | | | | | Transient units can be created via the bus API. They are configured via the method call parameters rather than on-disk files. They are subject to normal GC. Transient units currently may only be created for services (however, we will extend this), and currently only ExecStart= and the cgroup parameters can be configured (also to be extended). Transient units require a unique name, that previously had no configuration file on disk. A tool systemd-run is added that makes use of this functionality to run arbitrary command lines as transient services: $ systemd-run /bin/ping www.heise.de Will cause systemd to create a new transient service and run ping in it.
* Add __attribute__((const, pure, format)) in various placesZbigniew Jędrzejewski-Szmek2013-05-02
| | | | | | | | I'm assuming that it's fine if a _const_ or _pure_ function calls assert. It is assumed that the assert won't trigger, and even if it does, it can only trigger on the first call with a given set of parameters, and we don't care if the compiler moves the order of calls.
* Move bus_error to dbus-common and remove bus_error_message_or_strerrorSimon Peeters2013-04-18
| | | | | bus_error and bus_error_message_or_strerror dit almost exactly the same, so use only one of them and place it in dbus-common.
* core/transaction: replace a bare status_printf()Michal Schmidt2013-02-28
| | | | | | Like other status messages, this one too should not be printed unconditionally, but it should take the manager state into account. unit_status_printf() does that.
* core, systemctl: add support for irreversible jobsMichal Schmidt2013-02-22
| | | | | | | Add a new job mode: replace-irreversibly. Jobs enqueued using this mode cannot be implicitly canceled by later enqueued conflicting jobs. They can however still be canceled with an explicit "systemctl cancel" call.
* shutdown: issue a sync() as soon as shutdown.target is queuedLennart Poettering2013-02-09
|
* systemd: use unit logging macrosZbigniew Jędrzejewski-Szmek2013-01-06
|
* systemd: highlight ordering cycle deletionsOlivier Brunel2012-11-15
| | | | | | | | | Having unit(s) removed/not started, even if it solved the issue and allowed to boot successfully, should still be considered an error, as something clearly isn't right. This patch elevates the log message from warning to error, and adds a status message to make things more obvious.
* man: fix a bunch of typos in docsThomas Hindoe Paaboel Andersen2012-09-13
| | | | https://bugs.freedesktop.org/show_bug.cgi?id=54501
* systemd: added new dependency PartOfMichal Sekletar2012-07-26
| | | | | | | | | | | | This should address TODO item "new dependency type to "group" services in a target". Semantic of new dependency is as follows. Once configured it creates dependency which will cause that all dependent units get stopped if unit they all depend on is stopped or restarted. Usual use case would be configuring PartOf=some.target in template unit file and WantedBy=some.target in [Install] section and enabling desired number of instances. In this case starting one instance won't pull in target but stopping or starting target(in case of WantedBy is properly configured) will cause stop/start of all instances.
* unit: rename BindTo= to BindsTo=Lennart Poettering2012-07-13
| | | | | | | | all other dependencies are in 3rd person. Change BindTo= accordingly to BindsTo=. Of course, the dependency is widely used, hence we parse the old name too for compatibility.
* core: add NOP jobs, job type collapsingMichal Schmidt2012-04-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two of our current job types are special: JOB_TRY_RESTART, JOB_RELOAD_OR_START. They differ from other job types by being sensitive to the unit active state. They perform some action when the unit is active and some other action otherwise. This raises a question: when exactly should the unit state be checked to make the decision? Currently the unit state is checked when the job becomes runnable. It's more sensible to check the state immediately when the job is added by the user. When the user types "systemctl try-restart foo.service", he really intends to restart the service if it's running right now. If it isn't running right now, the restart is pointless. Consider the example (from Bugzilla[1]): sleep.service takes some time to start. hello.service has After=sleep.service. Both services get started. Two jobs will appear: hello.service/start waiting sleep.service/start running Then someone runs "systemctl try-restart hello.service". Currently the try-restart operation will block and wait for sleep.service/start to complete. The correct result is to complete the try-restart operation immediately with success, because hello.service is not running. The two original jobs must not be disturbed by this. To fix this we introduce two new concepts: - a new job type: JOB_NOP A JOB_NOP job does not do anything to the unit. It does not pull in any dependencies. It is always immediately runnable. When installed to a unit, it sits in a special slot (u->nop_job) where it never conflicts with the installed job (u->job) of a different type. It never merges with jobs of other types, but it can merge into an already installed JOB_NOP job. - "collapsing" of job types When a job of one of the two special types is added, the state of the unit is checked immediately and the job type changes: JOB_TRY_RESTART -> JOB_RESTART or JOB_NOP JOB_RELOAD_OR_START -> JOB_RELOAD or JOB_START Should a job type JOB_RELOAD_OR_START appear later during job merging, it collapses immediately afterwards. Collapsing actually makes some things simpler, because there are now fewer job types that are allowed in the transaction. [1] Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=753586
* service: introduce Type=idle and use it for gettysLennart Poettering2012-04-24
| | | | | | | | | | | | | Type=idle is much like Type=simple, however between the fork() and the exec() in the child we wait until PID 1 informs us that no jobs are left. This is mostly a cosmetic fix to make gettys appear only after all boot output is finished and complete. Note that this does not impact the normal job logic as we do not delay the completion of any jobs. We just delay the invocation of the actual binary, and only for services that otherwise would be of Type=simple.
* transaction: cancel jobs non-recursively on isolateMichal Schmidt2012-04-23
| | | | | | | Recursive cancellation of jobs would trigger OnFailure actions of dependent jobs. This is not desirable when isolating. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=798328
* transaction: abort does not need to use recursive deletionMichal Schmidt2012-04-24
| | | | | | Recursion is unnecessary, because we're deleting all transaction jobs anyway. And the recursive deletion produces debug messages that are pointless in transaction abort.
* transaction: fix detection of cycles involving installed jobsMichal Schmidt2012-04-24
| | | | | | | | | | | | | | | | | A transaction can be acyclic, but when it's added to installed jobs, a cycle may result. transaction_verify_order_one() attempts to detect these cases, but it fails because the installed jobs often have the exact generation number that makes them look as if they were walked already. Fix it by resetting the generation numbers of all installed jobs before detecting cycles. An alternative fix could be to add the generation counter to the Manager and use it instead of starting always from 1 in transaction_activate(). But I prefer not having to worry about it wrapping around.
* transaction: improve readabilityMichal Schmidt2012-04-24
| | | | | | | | The functions looked complicated with the nested loops with breaks, continues, and "while (again)". Here using goto actually makes them easier to understand. Also correcting the comment about redundant jobs.
* transaction: downgrade warnings about masked unitsLennart Poettering2012-04-22
|
* transaction: add missing emacs and license headersLennart Poettering2012-04-22
|
* transaction: add starting requirements for JOB_RESTARTMichal Schmidt2012-04-20
| | | | | | | | | | | | | | While having a Requires= dependency between units, the dependency is started automatically on "systemctl start", but it's not started on "systemctl restart". JOB_RESTART jobs did not pull the dependencies for starting into the transaction. https://bugzilla.redhat.com/show_bug.cgi?id=802770 Note that the other bug noted in comment #2 has been fixed already by avoiding the deletion of anchor jobs.
* transaction: remove checks for installedMichal Schmidt2012-04-20
| | | | | Transactions cannot contain installed jobs anymore. Remove the now pointless checks.
* transaction: rework merging with installed jobsMichal Schmidt2012-04-20
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously transactions could reference installed jobs. It made some issues difficult to fix. This sets new rules for jobs: A job cannot be both a member of a transaction and installed. When jobs are created, they are linked to a transaction. The whole transaction is constructed (with merging of jobs within, etc.). When it's complete, all the jobs are unlinked from it one by one and let to install themselves. It is during the installation when merging with previously installed jobs (from older transactions) is contemplated. Merging with installed jobs has different rules than merging within a transaction: - An installed conflicting job gets cancelled. It cannot be simply deleted, because someone might be waiting for its completion on DBus. - An installed, but still waiting, job can be safely merged into. - An installed and running job can be tricky. For some job types it is safe to just merge. For the other types we merge anyway, but put the job back into JOB_WAITING to allow it to run again. This may be suboptimal, but it is not currently possible to have more than one installed job for a unit. Note this also fixes a bug where the anchor job could be deleted during merging within the transaction.
* job: separate job_install()Michal Schmidt2012-04-20
| | | | Let the jobs install themselves.
* transaction: remove a couple of assertsMichal Schmidt2012-04-20
| | | | We already asserted these facts in the previous loop.
* transaction: remove the anchor linkMichal Schmidt2012-04-20
| | | | tr->anchor_job is sufficient.
* transaction: avoid garbage collecting the anchor jobMichal Schmidt2012-04-20
| | | | | Make sure the anchor job is never considered garbage, even if it has no links leading to it (this will be allowed in the next patch).
* transaction: simplify transaction_find_jobs_that_matter_to_anchor()Michal Schmidt2012-04-20
|
* transaction: change the linking of isolate jobs to the anchorMichal Schmidt2012-04-20
| | | | | | | When isolating, the JOB_STOP jobs have no parent job, so they are all peers of the real anchor job. This is a bit odd. Link them from the anchor job.
* transaction: maintain anchor_jobMichal Schmidt2012-04-20
| | | | Track which job is the anchor in the transaction.