summaryrefslogtreecommitdiff
path: root/src/core/transaction.c
AgeCommit message (Collapse)Author
2016-10-16tree-wide: use mfree moreZbigniew Jędrzejewski-Szmek
2016-07-25transaction: don't cancel jobs for units with IgnoreOnIsolate=true (#3671)Michael Olbrich
This is important if a job was queued for a unit but not yet started. Without this, the job will be canceled and is never executed even though IgnoreOnIsolate it set to 'true'.
2016-07-11treewide: fix typos and remove accidental repetition of wordsTorstein Husebø
2016-05-16core: don't log job status message in case job was effectively NOP (#3199)Michal Sekletar
We currently generate log message about unit being started even when unit was started already and job didn't do anything. This is because job was requested explicitly and hence became anchor job of the transaction thus we could not eliminate it. That is fine but, let's not pollute journal with useless log messages. $ systemctl start systemd-resolved $ systemctl start systemd-resolved $ systemctl start systemd-resolved Current state: $ journalctl -u systemd-resolved | grep Started May 05 15:31:42 rawhide systemd[1]: Started Network Name Resolution. May 05 15:31:59 rawhide systemd[1]: Started Network Name Resolution. May 05 15:32:01 rawhide systemd[1]: Started Network Name Resolution. After patch applied: $ journalctl -u systemd-resolved | grep Started May 05 16:42:12 rawhide systemd[1]: Started Network Name Resolution. Fixes #1723
2016-04-16tree-wide: use ERFKILL instead of ESHUTDOWN for "unit masked"Zbigniew Jędrzejewski-Szmek
If the error code ever leaks (we print the strerror error instead of providing our own), the message for ESHUTDOWN is "Cannot send after transport endpoint shutdown", which can be misleading. In particular it suggest that some mishandling of the dbus connection occured. Let's change that to ERFKILL which has the advantage that a) it sounds implausible as actual error, b) has the connotation of disabling something manually.
2016-04-12core: introduce MANAGER_IS_RELOADING() macroLennart Poettering
This replaces the old function call manager_is_reloading_or_reexecuting() which was used only at very few places. Use the new macro wherever we check whether we are reloading. This should hopefully make things a bit more readable, given the nature of Manager:n_reloading being a counter.
2016-03-17systemd: obey systemd.log_color configZbigniew Jędrzejewski-Szmek
Fixes #2845.
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2016-02-09Merge pull request #2565 from poettering/fix-2315Zbigniew Jędrzejewski-Szmek
2016-02-09core: change internal error code for masked units from EBADR to ESHUTDOWNLennart Poettering
This commit changes the mapping of the BUS_ERROR_UNIT_MASKED error to ESHUTDOWN. This error is used whenever the transaction engine is asked to operate on a masked unit. ESHUTDOWN is what is used for the similar case when the unit file enable/disable logic hits a masked unit file, hence is a natural candidate to be used here too. Background: before this patch both "job type not applicable" and "unit masked" where mapped to EBADR, which transaction_add_job_and_dependencies() then checked for. It actually wanted to check exclusively for the former error condition, not the latter but due to the same mapping this failed to work. This patch semi-undoes an accidental change made in caffa4ef700fdd0eadd6c0b2ef9925611672a1bc, however restores the error number to ESHUTDOWN instead of the original ENOSYS (for the reasons indicated above). To make this easier to grok for the future, I added comments to explaining which error conditions are checked for. Fixes: #2315
2016-01-28core: when propagating reload jobs, downgrade them to try-reloadLennart Poettering
Otherwise we might end up generating jobs that fail immediately. This follows the same logic that restart propagation follows.
2016-01-20Merge pull request #2085 from fbuihuu/more-use-of-check-load-stateLennart Poettering
core: use bus_unit_check_load_state() in transaction_add_job_and_depe…
2016-01-14transaction: downgrade warnings about wanted unit which are not foundFranck Bui
If a unit was pulled by a Wants= dependency but its unit file was not present then we logged this as an error. However Wants= might be used to configure a soft/optional dependency on another unit, ie. start an optional service only if it's installed otherwise simply skip it. In this case emitting an error doesn't look appropriate. But it's still an error if the optional dependency exists but its activation fails for any reasons.
2015-12-02core: use bus_unit_check_load_state() in transaction_add_job_and_dependencies()Franck Bui
2015-11-30core: do not warn about Wants depencencies on masked unitsZbigniew Jędrzejewski-Szmek
When masking is used to prevent a unit from being loaded, every transaction with dependent units would generate a warning. Downgrade this warning to debug level. transaction_add_job_and_dependencies only generated a few return values found in the table in bus_common_errors.c, and EADDRNOTAVAIL is not one of them, so do not try to suppress EADDRNOTAVAIL. https://bugzilla.redhat.com/show_bug.cgi?id=1278264
2015-11-16tree-wide: sort includesThomas Hindoe Paaboel Andersen
Sort the includes accoding to the new coding style.
2015-11-12core: drop "override" flag when building transactionsLennart Poettering
Now that we don't have RequiresOverridable= and RequisiteOverridable= dependencies anymore, we can get rid of tracking the "override" boolean for jobs in the job engine, as it serves no purpose anymore. While we are at it, fix some error messages we print when invoking functions that take the override parameter.
2015-11-12core: remove support for RequiresOverridable= and RequisiteOverridable=Lennart Poettering
As discussed at systemd.conf 2015 and on also raised on the ML: http://lists.freedesktop.org/archives/systemd-devel/2015-November/034880.html This removes the two XyzOverridable= unit dependencies, that were basically never used, and do not enhance user experience in any way. Most folks looking for the functionality this provides probably opt for the "ignore-dependencies" job mode, and that's probably a good idea. Hence, let's simplify systemd's dependency engine and remove these two dependency types (and their inverses). The unit file parser and the dbus property parser will now redirect the settings/properties to result in an equivalent non-overridable dependency. In the case of the unit file parser we generate a warning, to inform the user. The dbus properties for this unit type stay available on the unit objects, but they are now hidden from usual introspection and will always return the empty list when queried. This should provide enough compatibility for the few unit files that actually ever made use of this.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-09-22cgtop: underline table headerLennart Poettering
Let's underline the header line of the table shown by cgtop, how it is customary for tables. In order to do this, let's introduce new ANSI underline macros, and clean up the existing ones as side effect.
2015-09-11transaction: clarify via void-casting that we ignore the pipe2() return ↵Lennart Poettering
value for a reason
2015-09-09tree-wide: drop {} from one-line if blocksLennart Poettering
Patch via coccinelle.
2015-09-09tree-wide: don't do assignments within if checksLennart Poettering
Turn this: if ((r = foo()) < 0) { ... into this: r = foo(); if (r < 0) { ...
2015-05-21core: properly handle jobs that are suppressed to JOB_NOPs when propagating ↵Lennart Poettering
restarts
2015-05-19core: when propagating restart requests due to deps, downgrade restart to ↵Lennart Poettering
try-restart Previously, if a service A depended on a service B via Requires=, and A was not running and B restarted this would trigger a start of A as well, since the restart was propagated as restart independently of the state of A. This patch ensures that a restart of B would be propagated as a try-restart to A, thus not changing its state if it isn't up. http://lists.freedesktop.org/archives/systemd-devel/2015-May/032061.html
2015-05-19core: sd_bus_error() already checks for NULL, no need to duplicate checkLennart Poettering
2015-05-19core: reinstate propagation of stop/restart jobs via RequsiteOf dependenciesLennart Poettering
This reverts the primary effect of be7d9ff730cb88d7c6a869dd5c47754c78ceaef2. After all Requisite= should be close to Requires=, without the one exception that it doesn't pull in dependencies on start. However, reverse deps on stop/restart should be treated the same way as for Restart=, and this is already documented in the man page, hence stick to it. http://lists.freedesktop.org/archives/systemd-devel/2015-May/032049.html
2015-05-11core,network: major per-object logging reworkLennart Poettering
This changes log_unit_info() (and friends) to take a real Unit* object insted of just a unit name as parameter. The call will now prefix all logged messages with the unit name, thus allowing the unit name to be dropped from the various passed romat strings, simplifying invocations drastically, and unifying log output across messages. Also, UNIT= vs. USER_UNIT= is now derived from the Manager object attached to the Unit object, instead of getpid(). This has the benefit of correcting the field for --test runs. Also contains a couple of other logging improvements: - Drops a couple of strerror() invocations in favour of using %m. - Not only .mount units now warn if a symlinks exist for the mount point already, .automount units do that too, now. - A few invocations of log_struct() that didn't actually pass any additional structured data have been replaced by simpler invocations of log_unit_info() and friends. - For structured data a new LOG_UNIT_MESSAGE() macro has been added, that works like LOG_MESSAGE() but prefixes the message with the unit name. Similar, there's now LOG_LINK_MESSAGE() and LOG_NETDEV_MESSAGE(). - For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(), LOG_NETDEV_INTERFACE() macros have been added that generate the necessary per object fields. The old log_unit_struct() call has been removed in favour of these new macros used in raw log_struct() invocations. In addition to removing one more function call this allows generated structured log messages that contain two object fields, as necessary for example for network interfaces that are joined into another network interface, and whose messages shall be indexed by both. - The LOG_ERRNO() macro has been removed, in favour of log_struct_errno(). The latter has the benefit of ensuring that %m in format strings is properly resolved to the specified error number. - A number of logging messages have been converted to use log_unit_info() instead of log_info() - The client code in sysv-generator no longer #includes core code from src/core/. - log_unit_full_errno() has been removed, log_unit_full() instead takes an errno now, too. - log_unit_info(), log_link_info(), log_netdev_info() and friends, now avoid double evaluation of their parameters
2015-04-27core: coldplug all units which participate in jobs during coldpluggingIvan Shapovalov
This is yet another attempt to fix coldplugging order (more especially, the problem which happens when one creates a job during coldplugging and it references a not-yet-coldplugged unit). Now we forcibly coldplug all units which participate in jobs. This is a superset of previously implemented handling of the UNIT_TRIGGERS dependencies, so that handling is removed. http://lists.freedesktop.org/archives/systemd-devel/2015-April/031212.html https://bugs.freedesktop.org/show_bug.cgi?id=88401 (once again)
2015-04-11shared: add terminal-util.[ch]Ronny Chevalier
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
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.
2014-12-10sd-bus: move common errors src/shared/bus-errors.h → ↵Lennart Poettering
src/libsystemd/sd-bus/bus-common-errors.h Stuff in src/shared/ should not use stuff from src/libsystemd/ really.
2014-11-28treewide: more log_*_errno + return simplificationsMichal Schmidt
2014-11-28treewide: no need to negate errno for log_*_errno()Michal Schmidt
It corrrectly handles both positive and negative errno values.
2014-11-28treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt
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().
2014-11-27log: rearrange log function namingLennart Poettering
- 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.
2014-11-27core: fix transaction destructiveness check once moreMichal Schmidt
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.
2014-11-26core: fix check for transaction destructivenessMichal Schmidt
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.
2014-11-02Raise level of 'Found dependency...' linesZbigniew Jędrzejewski-Szmek
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
2014-10-30Convert the rest to sd_bus_errnomapZbigniew Jędrzejewski-Szmek
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.
2014-09-15hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt
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.
2014-07-31systemd-analyze verify: improve error messageZbigniew Jędrzejewski-Szmek
There's little sense in telling the user to look at the logs...
2014-06-26core/transaction: fix cycle break attempts outside transactionUoti Urpala
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
2014-06-22core/transaction: avoid misleading error message when unit not foundZbigniew Jędrzejewski-Szmek
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
2014-06-22core/transaction: reindent and split very long linesZbigniew Jędrzejewski-Szmek
2014-02-06transaction: print more information about conflicting jobsZbigniew Jędrzejewski-Szmek
Also remove some debug statement that should not have been committed.
2013-11-26core: add new "flush" job mode to cancel all other jobs when queuing a new jobLennart Poettering
2013-11-20core: convert PID 1 to libsystemd-busLennart Poettering
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.
2013-10-14list: make our list macros a bit easier to use by not requring type spec on ↵Lennart Poettering
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.
2013-09-16transaction.c: do not point users to logs when unit not foundZbigniew Jędrzejewski-Szmek
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