summaryrefslogtreecommitdiff
path: root/src/core/job.c
Commit message (Collapse)AuthorAgeFilesLines
* core/job: use new job ID when we failed to deserialize job IDYu Watanabe2023-04-271-0/+4
| | | | | | | | This is for the case when we fail to deserialize job ID. In job_install_deserialized(), we also check the job type, and that is for the case when we failed to deserialize the job. Let's gracefully handle the failure in deserializing the job ID. This is paranoia, and just for safety. Should not change any behavior.
* core/job: handle job ID overflow or conflict more sanelyYu Watanabe2023-04-271-1/+23
| | | | This is paranoia, and just for safety. Should not change any behavior.
* core/job: fix indentationYu Watanabe2023-04-271-2/+2
|
* core/job: add one more assertionYu Watanabe2023-04-271-0/+1
| | | | In this stage, the unit should not have installed job of the type.
* Uphold/StopWhenUnneeded/BindsTo: requeue when job finishesLuca Boccassi2023-04-131-0/+6
| | | | | | | | When a unit is upheld and fails, and there are no state changes in the upholder, it will not be retried, which is against what the documentation suggests. Requeue when the job finishes. Same for the other two queues.
* doc: correct wrong use "'s" contractionsJan Engelhardt2023-03-071-1/+1
|
* tree-wide: drop () around the first argument of a ternary opZbigniew Jędrzejewski-Szmek2022-10-111-3/+3
| | | | https://github.com/systemd/systemd/pull/24933#discussion_r991242789
* tree-wide: use nested ASSERT_PTRDavid Tardon2022-09-141-5/+1
|
* tree-wide: check parameter before dereferencingDavid Tardon2022-09-131-2/+4
|
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-2/+1
|
* Merge pull request #24404 from thatguystone/socket-jobsLennart Poettering2022-09-051-3/+21
|\ | | | | job: Don't discard propagated restart jobs when unit is activating
| * job: Don't discard propagated restart jobs when unit is activatingAndrew Stone2022-08-251-3/+21
| | | | | | | | | | | | | | | | When a service unit Requires= a socket, and the socket is restarted while the service is in state=activating, the propagated restart is being discarded. This is contrary to the documentation for Requires=, which states "this unit will be stopped (or restarted) if one of the other units is explicitly stopped (or restarted)".
* | tree-wide: Use "unmet" for condition checks, not "failed"Colin Walters2022-09-011-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Often I end up debugging a problem on a system, and I do e.g. `journalctl --grep=failed|error`. The use of the term "failed" for condition checks adds a *lot* of unnecessary noise into this. Now, I know this regexp search isn't precise, but it has proven to be useful to me. I think "failed" is too strong of a term as a baseline, and also just stands out to e.g. humans watching their servers boot or whatever. The term "met condition" is fairly widely used, e.g. https://stackoverflow.com/questions/63751794/what-does-the-condition-is-met-exactly-mean-in-programming-languages Use that instead.
* | core: add basic infrastructure to record unit activation informationLuca Boccassi2022-08-231-3/+26
|/ | | | | | | Not wired in by any unit type yet, just the basic to allocate, ref, deref and plug in to other unit types. Includes recording the trigger unit name and passing it to the triggered unit as TRIGGER_UNIT= env var.
* core: drop unused BUS_UNIT_QUEUE_RETURN_SKIP_ON_CONDITION_FAIL flagLuca Boccassi2022-08-031-2/+2
| | | | We'll refactor and implement the feature in a different way
* tree-wide: use LOG_MESSAGE() where possibleZbigniew Jędrzejewski-Szmek2022-05-111-7/+7
| | | | | | | Also break some long lines for more uniform formatting. No functional change. I went over all log_struct, log_struct_errno, log_unit_struct, log_unit_struct_errno calls, and they seem fine.
* core: split $MONITOR_METADATA and return it only if a single unit triggers ↵Luca Boccassi2022-03-101-12/+0
| | | | | | | | | | | OnFailure/OnSuccess Remove the list logic, and simply skip passing metadata if more than one unit triggered an OnFailure/OnSuccess handler. Instead of a single env var to loop over, provide each separate item as its own variable. Fixes https://github.com/systemd/systemd/issues/22370
* core: simply freeing list in job_free()Luca Boccassi2022-02-021-6/+2
| | | | Follow-up for cdebedb4d40277aad62a7734ba920b4033228197
* service: pass service exit status to spawned On{Failure,Success}= dependencyPeter Morrow2021-12-131-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a service exits and triggers either an OnFailure= or OnSuccess= dependency we now set a new environment variable for the ExecStart= and ExecStartPre= process. This variable $MONITOR_METADATA exposes the metadata relating to the service which triggered the dependency. MONITOR_METADATA takes the following form: MONITOR_METADATA="SERVICE_RESULT=<result-string0>,EXIT_CODE=<exit-code0>,EXIT_STATUS=<exit-status0>,INVOCATION_ID=<id>,UNIT=<triggering-unit0.service>;SERVICE_RESULT=<result-stringN>,EXIT_CODE=<exit-codeN>,=EXIT_STATUS=<exit-statusN>,INVOCATION_ID=<id>,UNIT=<triggering-unitN.service>" MONITOR_METADATA is space separated set of metadata relating to the service(s) which triggered the dependency. This is a list since if we have 2 services which trigger the same dependency then the dependency start job may be merged. In this case we need to pass both service metadata to the triggered service. If there is no job merging then MONITOR_METADATA will be a single entry. For example, in the case we had a service "failer.service" which triggers "failer-handler.service", the following variable is exported to the ExecStart= and ExecStartPre= processes in failer-handler.service: MONITOR_METADATA="SERVICE_RESULT=exit-code,EXIT_CODE=exited,EXIT_STATUS=1,INVOCATION_ID=67c657ed7b34466ea369abdf994c6393,UNIT=failer.service" In another example where we have failer.service and failer2.service which both also trigger failer-handler.service then the start job for failer-handler.service may be merged and we might get the following: MONITOR_METADATA="SERVICE_RESULT=exit-code,EXIT_CODE=exited,EXIT_STATUS=1,INVOCATION_ID=16a93ad196c94109990fb8b9aa5eef5f,UNIT=failer.service;SERVICE_RESULT=exit-code,EXIT_CODE=exited,EXIT_STATUS=1,INVOCATION_ID=ff70131e4cc145e994fb621de25a3e8f,UNIT=failer2.service"
* core: add StartUnitWithFlags DBUS methodLuca Boccassi2021-12-071-2/+2
| | | | | | | | | | | | | | | | When an activation job is skipped because of a Condition*= setting failing, currently the JobRemoved signal lists 'done' as the result, just as with a successful job. This is a problem when doing dbus activation: dbus-broker will receive a signal that says the job was successful, so then it moves into a state where it waits for the requested name to appear on the bus, but that never happens because the job was actually skipped. Add a new StartUnitWithFlags that changes the behaviour of the JobRemoved signal to list 'done' or 'skipped'. Fixes #21520
* pid1: add a manager_trigger_run_queue() helperLennart Poettering2021-11-121-6/+2
| | | | | | | | We have two different places where we re-trigger the run queue now. let's unify it under a common function, that is part of the Manager code. Follow-up for #20953
* cgroup: re-evaluate startup units during shutdown as wellPeter Morrow2021-09-241-0/+2
| | | | | | | | | Apply startup cgroup configuration options to the shutdown phase as well. I.e. all directives prefixed with Startup are applied during boot and shutdown. For example: StartupAllowedCPU= applies during boot and shutdown. AllowedCPUs= applies during normal runtime.
* core: Add information on which condition failed to the job done messageDaan De Meyer2021-08-281-11/+43
| | | | | | | | When a job is skipped, it's useful to know exactly which condition failed so let's add this information to the error message. To avoid having to dynamically generate a format string, we special case the formatting of condition failed messages.
* Revert "core: Add information on which condition failed to job skipped ↵Lennart Poettering2021-08-271-34/+11
| | | | | | format string" This reverts commit c97bef458b6e59079c9613ec755c1c6513c1c655.
* core: Add information on which condition failed to job skipped format stringDaan De Meyer2021-08-261-11/+34
| | | | | | | | When a job is skipped, it's useful to know exactly which condition failed so let's add this information to the error message. Because we now return an allocated string from job_done_message_format(), make sure we strdup() the other formats as well so the caller can safely free the string returned by job_done_message_format().
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-3/+3
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* core: align string tablesZbigniew Jędrzejewski-Szmek2021-07-191-25/+25
|
* Merge pull request #20058 from keszybz/status-formatZbigniew Jędrzejewski-Szmek2021-07-011-280/+208
|\ | | | | Implement StatusUnitFormat=combined and prettify Descriptions
| * core: rework unit printing and implement 'combined' formatZbigniew Jędrzejewski-Szmek2021-06-301-280/+208
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code to print unit status formats had a long history, and became a hard-to-manage mess of duplicate code parts. We would use sprintf() to format a string, and then call sprintf() again… The code is reworked to avoid repeated formattings and to streamline printing to the log and the console. The approach used in this patch is a bit more complex then in patches by Colin Walter and Paweł Marciniak, because an allocation is only done if "combined" format is used. In other cases we return the existing ->id or ->description strings. The caller can also control whether a shorter or longer status string should be used. This way the caller can use a shorter format where it makes sense, for example in the cylon eye output, where we don't have enough horizontal space. Patch is based on Colin Walters' https://github.com/systemd/systemd/pull/15957, and Paweł Marciniak's patch posted on fedora-devel. Note: for some reason, the functions for printing of start and stop messages were sepearated by some unrelated functions. They are moved to be consecutive, but this makes the much more verbose than it would be otherwise. I found it useful to view in gitk's "new" mode. Co-authored-by: Colin Walters <walters@verbum.org> Co-authored-by: Paweł Marciniak <sunwire+git@gmail.com> Output from a Fedora Rawhide container boot (w/ some follow-up patches to tweak Descriptions): Welcome to Fedora 35 (Rawhide Prerelease)! Queued start job for default target graphical.target. [ OK ] Created slice system-getty.slice - Slice /system/getty. [ OK ] Created slice system-modprobe.slice - Slice /system/modprobe. [ OK ] Created slice system-sshd\x2dkeygen.slice - Slice /system/sshd-keygen. [ OK ] Created slice user.slice - User and Session Slice. [ OK ] Started systemd-ask-password-console.path - Dispatch Password Requests to Console Directory Watch. [ OK ] Started systemd-ask-password-wall.path - Forward Password Requests to Wall Directory Watch. [ OK ] Reached target cryptsetup.target - Local Encrypted Volumes. [ OK ] Reached target paths.target - Path Units. [ OK ] Reached target remote-cryptsetup.target - Remote Encrypted Volumes. [ OK ] Reached target remote-fs.target - Remote File Systems. [ OK ] Reached target slices.target - Slice Units. [ OK ] Reached target swap.target - Swaps. [ OK ] Reached target veritysetup.target - Local Verity Integrity Protected Volumes. [ OK ] Listening on systemd-coredump.socket - Process Core Dump Socket. [ OK ] Listening on systemd-initctl.socket - initctl Compatibility Named Pipe. [ OK ] Listening on systemd-journald-dev-log.socket - Journal Socket (/dev/log). [ OK ] Listening on systemd-journald.socket - Journal Socket. [ OK ] Listening on systemd-networkd.socket - Network Service Netlink Socket. [ OK ] Listening on systemd-userdbd.socket - User Database Manager Socket. Mounting dev-hugepages.mount - Huge Pages File System... Starting systemd-journald.service - Journal Service... Starting systemd-remount-fs.service - Remount Root and Kernel File Systems... Starting systemd-sysctl.service - Apply Kernel Variables... [ OK ] Mounted dev-hugepages.mount - Huge Pages File System. [ OK ] Finished systemd-remount-fs.service - Remount Root and Kernel File Systems. Starting systemd-hwdb-update.service - Rebuild Hardware Database... Starting systemd-sysusers.service - Create System Users... [ OK ] Finished systemd-sysctl.service - Apply Kernel Variables. [ OK ] Started systemd-journald.service - Journal Service. Starting systemd-journal-flush.service - Flush Journal to Persistent Storage... [ OK ] Finished systemd-sysusers.service - Create System Users. Starting systemd-tmpfiles-setup-dev.service - Create Static Device Nodes in /dev... [ OK ] Finished systemd-tmpfiles-setup-dev.service - Create Static Device Nodes in /dev. [ OK ] Reached target local-fs-pre.target - Preparation for Local File Systems. [ OK ] Reached target local-fs.target - Local File Systems. [ OK ] Reached target machines.target - Containers. Starting dracut-shutdown.service - Restore /run/initramfs on shutdown... Starting ldconfig.service - Rebuild Dynamic Linker Cache... [ OK ] Finished dracut-shutdown.service - Restore /run/initramfs on shutdown. [ OK ] Finished ldconfig.service - Rebuild Dynamic Linker Cache. [ OK ] Finished systemd-journal-flush.service - Flush Journal to Persistent Storage. Starting systemd-tmpfiles-setup.service - Create Volatile Files and Directories... [ OK ] Finished systemd-tmpfiles-setup.service - Create Volatile Files and Directories. Starting systemd-journal-catalog-update.service - Rebuild Journal Catalog... Starting systemd-oomd.service - Userspace Out-Of-Memory (OOM) Killer... Starting systemd-update-utmp.service - Update UTMP about System Boot/Shutdown... Starting systemd-userdbd.service - User Database Manager... [ OK ] Finished systemd-update-utmp.service - Update UTMP about System Boot/Shutdown. [ OK ] Finished systemd-journal-catalog-update.service - Rebuild Journal Catalog. [ OK ] Started systemd-userdbd.service - User Database Manager. [ OK ] Started systemd-oomd.service - Userspace Out-Of-Memory (OOM) Killer. [ OK ] Finished systemd-hwdb-update.service - Rebuild Hardware Database. Starting systemd-networkd.service - Network Configuration... Starting systemd-update-done.service - Update is Completed... [ OK ] Finished systemd-update-done.service - Update is Completed. [ OK ] Reached target sysinit.target - System Initialization. [ OK ] Started dnf-makecache.timer - dnf makecache --timer. [ OK ] Started logrotate.timer - Daily rotation of log files. [ OK ] Started systemd-tmpfiles-clean.timer - Daily Cleanup of Temporary Directories. [ OK ] Reached target timers.target - Timer Units. [ OK ] Listening on dbus.socket - D-Bus System Message Bus Socket. [ OK ] Reached target sockets.target - Socket Units. [ OK ] Reached target basic.target - Basic System. [ OK ] Reached target sshd-keygen.target. Starting sysstat.service - Resets System Activity Logs... Starting systemd-homed.service - Home Area Manager... Starting systemd-logind.service - User Login Management... Starting dbus-broker.service - D-Bus System Message Bus... [FAILED] Failed to start sysstat.service - Resets System Activity Logs. See 'systemctl status sysstat.service' for details. [ OK ] Started dbus-broker.service - D-Bus System Message Bus. [ OK ] Started systemd-homed.service - Home Area Manager. [ OK ] Finished systemd-homed-activate.service - Home Area Activation. [ OK ] Started systemd-logind.service - User Login Management. [ OK ] Started systemd-networkd.service - Network Configuration. Starting systemd-networkd-wait-online.service - Wait for Network to be Configured... Starting systemd-resolved.service - Network Name Resolution... [ OK ] Started systemd-resolved.service - Network Name Resolution. [ OK ] Reached target network.target - Network. [ OK ] Reached target nss-lookup.target - Host and Network Name Lookups. Starting sshd.service - OpenSSH server daemon... Starting systemd-user-sessions.service - Permit User Sessions... [ OK ] Finished systemd-user-sessions.service - Permit User Sessions. [ OK ] Started console-getty.service - Console Getty. [ OK ] Reached target getty.target - Login Prompts. [ OK ] Started sshd.service - OpenSSH server daemon. [ OK ] Reached target multi-user.target - Multi-User System. [ OK ] Reached target graphical.target - Graphical Interface. Starting systemd-update-utmp-runlevel.service - Update UTMP about System Runlevel Changes... [ OK ] Finished systemd-update-utmp-runlevel.service - Update UTMP about System Runlevel Changes. Fedora 35 (Rawhide Prerelease) Kernel 5.12.12-300.fc34.x86_64 on an x86_64 (console) rawhide login: [ OK ] Stopped session-24.scope - Session 24 of User zbyszek. [ OK ] Removed slice system-getty.slice - Slice /system/getty. [ OK ] Removed slice system-modprobe.slice - Slice /system/modprobe. [ OK ] Removed slice system-sshd\x2dkeygen.slice - Slice /system/sshd-keygen. [ OK ] Stopped target graphical.target - Graphical Interface. [ OK ] Stopped target multi-user.target - Multi-User System. [ OK ] Stopped target getty.target - Login Prompts. [ OK ] Stopped target machines.target - Containers. [ OK ] Stopped target nss-lookup.target - Host and Network Name Lookups. [ OK ] Stopped target remote-cryptsetup.target - Remote Encrypted Volumes. [ OK ] Stopped target timers.target - Timer Units. [ OK ] Stopped dnf-makecache.timer - dnf makecache --timer. [ OK ] Stopped logrotate.timer - Daily rotation of log files. [ OK ] Stopped systemd-tmpfiles-clean.timer - Daily Cleanup of Temporary Directories. [ OK ] Closed systemd-coredump.socket - Process Core Dump Socket. Stopping console-getty.service - Console Getty... Stopping dracut-shutdown.service - Restore /run/initramfs on shutdown... Stopping sshd.service - OpenSSH server daemon... Stopping systemd-logind.service - User Login Management... Stopping systemd-oomd.service - Userspace Out-Of-Memory (OOM) Killer... Stopping user@1000.service - User Manager for UID 1000... [ OK ] Stopped systemd-oomd.service - Userspace Out-Of-Memory (OOM) Killer. [ OK ] Stopped systemd-networkd-wait-online.service - Wait for Network to be Configured. [ OK ] Stopped sshd.service - OpenSSH server daemon. [ OK ] Stopped console-getty.service - Console Getty. [ OK ] Stopped dracut-shutdown.service - Restore /run/initramfs on shutdown. [ OK ] Stopped target sshd-keygen.target. [ OK ] Stopped systemd-logind.service - User Login Management. [ OK ] Stopped user@1000.service - User Manager for UID 1000. Stopping user-runtime-dir@1000.service - User Runtime Directory /run/user/1000... [ OK ] Unmounted run-user-1000.mount - /run/user/1000. [ OK ] Stopped user-runtime-dir@1000.service - User Runtime Directory /run/user/1000. [ OK ] Removed slice user-1000.slice - User Slice of UID 1000. Stopping systemd-user-sessions.service - Permit User Sessions... [ OK ] Stopped systemd-user-sessions.service - Permit User Sessions. [ OK ] Stopped target network.target - Network. [ OK ] Stopped target remote-fs.target - Remote File Systems. Stopping systemd-homed-activate.service - Home Area Activation... Stopping systemd-resolved.service - Network Name Resolution... [ OK ] Stopped systemd-resolved.service - Network Name Resolution. Stopping systemd-networkd.service - Network Configuration... [ OK ] Stopped systemd-homed-activate.service - Home Area Activation. Stopping systemd-homed.service - Home Area Manager... [ OK ] Stopped systemd-homed.service - Home Area Manager. [ OK ] Stopped target basic.target - Basic System. [ OK ] Stopped target paths.target - Path Units. [ OK ] Stopped target slices.target - Slice Units. [ OK ] Removed slice user.slice - User and Session Slice. [ OK ] Stopped target sockets.target - Socket Units. Stopping dbus-broker.service - D-Bus System Message Bus... [ OK ] Stopped dbus-broker.service - D-Bus System Message Bus. [ OK ] Closed dbus.socket - D-Bus System Message Bus Socket. [ OK ] Stopped target sysinit.target - System Initialization. [ OK ] Stopped target cryptsetup.target - Local Encrypted Volumes. [ OK ] Stopped systemd-ask-password-console.path - Dispatch Password Requests to Console Directory Watch. [ OK ] Stopped systemd-ask-password-wall.path - Forward Password Requests to Wall Directory Watch. [ OK ] Stopped target veritysetup.target - Local Verity Integrity Protected Volumes. [ OK ] Stopped systemd-update-done.service - Update is Completed. [ OK ] Stopped ldconfig.service - Rebuild Dynamic Linker Cache. [ OK ] Stopped systemd-hwdb-update.service - Rebuild Hardware Database. [ OK ] Stopped systemd-journal-catalog-update.service - Rebuild Journal Catalog. Stopping systemd-update-utmp.service - Update UTMP about System Boot/Shutdown... [ OK ] Stopped systemd-networkd.service - Network Configuration. [ OK ] Closed systemd-networkd.socket - Network Service Netlink Socket. [ OK ] Stopped systemd-sysctl.service - Apply Kernel Variables. [ OK ] Stopped systemd-update-utmp.service - Update UTMP about System Boot/Shutdown. [ OK ] Stopped systemd-tmpfiles-setup.service - Create Volatile Files and Directories. [ OK ] Stopped target local-fs.target - Local File Systems. Unmounting home.mount - /home... Unmounting run-credentials-systemd\x2dsysusers.se…e.mount - /run/credentials/systemd-sysusers.service... Unmounting tmp.mount - Temporary Directory /tmp... [ OK ] Unmounted home.mount - /home. [ OK ] Unmounted tmp.mount - Temporary Directory /tmp. [ OK ] Unmounted run-credentials-systemd\x2dsysusers.service.mount - /run/credentials/systemd-sysusers.service. [ OK ] Stopped target local-fs-pre.target - Preparation for Local File Systems. [ OK ] Stopped target swap.target - Swaps. [ OK ] Reached target umount.target - Unmount All Filesystems. [ OK ] Stopped systemd-tmpfiles-setup-dev.service - Create Static Device Nodes in /dev. [ OK ] Stopped systemd-sysusers.service - Create System Users. [ OK ] Stopped systemd-remount-fs.service - Remount Root and Kernel File Systems. [ OK ] Reached target shutdown.target - System Shutdown. [ OK ] Reached target final.target - Late Boot Services. [ OK ] Finished systemd-poweroff.service - System Power Off. [ OK ] Reached target poweroff.target - System Power Off. Sending SIGTERM to remaining processes... Sending SIGKILL to remaining processes... All filesystems, swaps, loop devices, MD devices and DM devices detached. Powering off.
* | Merge pull request #20030 from keszybz/exec_fd-event-sourceZbigniew Jędrzejewski-Szmek2021-07-011-3/+3
|\ \ | |/ |/| exec_fd event source rework
| * core: disable event sources before unreffing themZbigniew Jędrzejewski-Szmek2021-05-121-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This mirrors the change done for systemd-resolved in 97935302283729c9206b84f5e00b1aff0f78ad19. Quoting that patch: > We generally operate on the assumption that a source is "gone" as soon as we > unref it. This is generally true because we have the only reference. But if > something else holds the reference, our unref doesn't really stop the source > and it could fire again. In particular, we take temporary references from sd-event code, and when called from an sd-event callback, we could temporarily see this elevated reference count. This patch doesn't seem to change anything, but I think it's nicer to do the same change as in other places and not rely on _unref() immediately disabling the source.
* | core: add new OnSuccess= dependency typeLennart Poettering2021-05-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is similar to OnFailure= but is activated whenever a unit returns into inactive state successfully. I was always afraid of adding this, since it effectively allows building loops and makes our engine Turing complete, but it pretty much already was it was just hidden. Given that we have per-unit ratelimits as well as an event loop global ratelimit I feel safe to add this finally, given it actually is useful. Fixes: #13386
* | core: rebreak a few commentsLennart Poettering2021-05-251-22/+16
| |
* | core: split dependency types into atomsLennart Poettering2021-05-251-46/+38
| |
* | alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()Lennart Poettering2021-05-191-6/+6
|/ | | | | | | | | | | | | | | | | | | | | | | | We recently started making more use of malloc_usable_size() and rely on it (see the string_erase() story). Given that we don't really support sytems where malloc_usable_size() cannot be trusted beyond statistics anyway, let's go fully in and rework GREEDY_REALLOC() on top of it: instead of passing around and maintaining the currenly allocated size everywhere, let's just derive it automatically from malloc_usable_size(). I am mostly after this for the simplicity this brings. It also brings minor efficiency improvements I guess, but things become so much nicer to look at if we can avoid these allocation size variables everywhere. Note that the malloc_usable_size() man page says relying on it wasn't "good programming practice", but I think it does this for reasons that don't apply here: the greedy realloc logic specifically doesn't rely on the returned extra size, beyond the fact that it is equal or larger than what was requested. (This commit was supposed to be a quick patch btw, but apparently we use the greedy realloc stuff quite a bit across the codebase, so this ends up touching *a*lot* of code.)
* Merge pull request #18863 from keszybz/cmdline-escapingLennart Poettering2021-05-071-1/+1
|\ | | | | Escape command lines properly
| * Flagsify EscapeStyle and make ESCAPE_BACKSLASH_ONELINE implicitZbigniew Jędrzejewski-Szmek2021-04-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | I want to tweak behaviour further, and that'll be easier when "style" is converted to a bitfield. Some callers used ESCAPE_BACKSLASH_ONELINE, and others not. But the ones that didn't, simply didn't care, because the argument was assumed to be one-line anyway (e.g. a service name). In environment-generator, this could make a difference. But I think it's better to escape the newlines there too. So newlines are now always escaped, to simplify the code and the test matrix.
* | core: apply LogLevelMax to messages about unitsRyan Hendrickson2021-05-031-38/+39
| | | | | | | | | | | | | | | | | | | | This commit applies the filtering imposed by LogLevelMax on a unit's processes to messages logged by PID1 about the unit as well. The target use case for this feature is a service that runs on a timer many times an hour, where the system administrator decides that writing a generic success message to the journal every few minutes or seconds adds no diagnostic value and isn't worth the clutter or disk I/O.
* | tree-wide: avoid uninitialized warning on _cleanup_ variablesLuca Boccassi2021-04-141-1/+1
|/ | | | | | | With some versions of the compiler, the _cleanup_ attr makes it think the variable might be freed/closed when uninitialized, even though it cannot happen. The added cost is small enough to be worth the benefit, and optimized builds will help reduce it even further.
* core: update setings on the unit and job as the result of ExecCondition=Anita Zhang2021-01-221-2/+1
| | | | | | | | Update ExecCondition= to set Unit->condition_result and return JOB_DONE in the Job results if the check fails so as to match the current behavior of ConditionXYZ= w.r.t units/jobs dependency checks. Fixes: #18207
* core: job - use hashmap_ensure_putSusant Sahani2021-01-171-5/+1
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* tree-wide: define iterator inside of the macroZbigniew Jędrzejewski-Szmek2020-09-081-17/+11
|
* core/job: adjust whitespace and commentZbigniew Jędrzejewski-Szmek2020-07-221-2/+3
|
* Revert "job: Don't mark as redundant if deps are relevant"Dave Reisner2020-06-231-44/+7
| | | | | | | | | | | This reverts commit 097537f07a2fab3cb73aef7bc59f2a66aa93f533. At least Fedora and Debian have already reverted this at the distro level because it causes more problems than it solves. Arch is debating reverting it as well [0] but would strongly prefer that this happens upstream first. Fixes #15188. [0] https://bugs.archlinux.org/task/66458
* manager: free the jobs hashmap after we have no jobsZbigniew Jędrzejewski-Szmek2020-05-281-0/+4
| | | | | | | | After a larger transaction, e.g. after bootup, we're left with an empty hashmap with hundreds of buckets. Long-term, it'd be better to size hashmaps down when they are less than 1/4 full, but even if we implement that, jobs hashmap is likely to be empty almost always, so it seems useful to deallocate it once the jobs count reaches 0.
* core: add debug log when a job in the activation queue is not runnableLuca Boccassi2020-04-221-2/+10
| | | | | | | When a job is skipped due its dependencies not being ready, log a debug message saying what is holding it back. This was very useful with transient units timing out to figure out where the problem was.
* tree-wide: spellcheck using codespellZbigniew Jędrzejewski-Szmek2020-04-161-1/+1
| | | | Fixes #15436.
* Use Finished instead of Started for Type=oneshot services (#14851)Zbigniew Jędrzejewski-Szmek2020-03-051-2/+8
| | | | | | | | | | | UnitStatusMessageFormats.finished_job, if present, will be called with the same arguments as job_get_done_status_message_format() to provide a format string appropriate for the context This commit replaces "Started" with "Finished" for started oneshot units, as mentioned in the referenced issue Closes #2458.
* pid1: when showing error status, do not switch to status=temporaryZbigniew Jędrzejewski-Szmek2020-03-011-5/+4
| | | | | | | | | | | | | | We would flip to status=temporary mode on the first error, and then switch back to status=auto after the initial transaction was done. This isn't very useful, because usually all the messages about successfully started units and not related to the original failure. In fact, all those messages most likely cause the information about the prime error to scroll off screen. And if the user requested quiet boot, there's no reason to think that they care about those success messages. Also, when logging about dependency cycles, treat this similarly to a unit error and show the message even if the status is "soft disabled" (before we wouldn't show it in that case).