summaryrefslogtreecommitdiff
path: root/src/core/job.c
AgeCommit message (Collapse)Author
2013-11-26core: add new "flush" job mode to cancel all other jobs when queuing a new jobLennart Poettering
2013-11-25core: dispatch run queue only if there's nothing else to doLennart Poettering
Always read all external events before we decide what we do next.
2013-11-22job: fix serializationLennart 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-11-13Fix possible lack of status messages on shutdown/rebootOlivier Brunel
Since 31a7eb86 the output on console can be disabled to avoid colliding with gettys. However, it could also lead to a lack of messages during shutdown/reboot.
2013-11-08Remove dead code and unexport some callsLennart Poettering
"make check-api-unused" informs us about code that is not used anymore or that is exported but only used internally. Fix these all over the place.
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-17Make tmpdir removal asynchronousZbigniew Jędrzejewski-Szmek
https://bugs.freedesktop.org/show_bug.cgi?id=68232
2013-06-28core: add transient unitsLennart Poettering
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.
2013-05-02Add __attribute__((const, pure, format)) in various placesZbigniew Jędrzejewski-Szmek
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.
2013-04-23unit: rework trigger dependency logicLennart Poettering
Instead of having explicit type-specific callbacks that inform the triggering unit when a triggered unit changes state, make this generic so that state changes are forwarded betwee any triggered and triggering unit. Also, get rid of UnitRef references from automount, timer, path units, to the units they trigger and rely exclsuively on UNIT_TRIGGER type dendencies.
2013-04-05Use initalization instead of explicit zeroingZbigniew Jędrzejewski-Szmek
Before, we would initialize many fields twice: first by filling the structure with zeros, and then a second time with the real values. We can let the compiler do the job for us, avoiding one copy. A downside of this patch is that text gets slightly bigger. This is because all zero() calls are effectively inlined: $ size build/.libs/systemd text data bss dec hex filename before 897737 107300 2560 1007597 f5fed build/.libs/systemd after 897873 107300 2560 1007733 f6075 build/.libs/systemd … actually less than 1‰. A few asserts that the parameter is not null had to be removed. I don't think this changes much, because first, it is quite unlikely for the assert to fail, and second, an immediate SEGV is almost as good as an assert.
2013-03-02job: print the "OK" status messages in normal greenMichal Schmidt
The "OK" status messages should not draw attention to themselves. It's better if they're not printed in bright/bold. Leave that to errors and warnings. Use a plain inconspicuous enterprisey green.
2013-02-28util, core: add support for ephemeral status linesMichal Schmidt
Ephemeral status lines do not end with a newline and they expect to be overwritten by the next printed status line.
2013-02-28core: redefine unit_status_printf()Michal Schmidt
Take advantage of the fact that almost all callers want to pass unit description as the last parameter. Those who don't can use the more flexible manager_status_printf().
2013-02-27core: keep track of the number of JOB_RUNNING jobsMichal Schmidt
2013-02-22core, systemctl: add support for irreversible jobsMichal Schmidt
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.
2013-02-09shutdown: issue a sync() as soon as shutdown.target is queuedLennart Poettering
2013-01-25job: fix merging with --ignore-dependenciesMichal Schmidt
This fixes a bug where a job with --ignore-dependencies would wait for other jobs because it merged into a previously queued job.
2013-01-18core: log USER_UNIT instead of UNIT if in user sessionMirco Tischler
2013-01-15core: use correct argument of type JobResultMichal Sekletar
2013-01-06systemd: use unit logging macrosZbigniew Jędrzejewski-Szmek
2012-10-25job: avoid recursion into transaction code from job cancelationMichal Schmidt
I hit an "assert(j->installed)" failure in transaction_apply(). Looking into the backtrace I saw what happened: 1. The system was booting. var.mount/start was an installed job. 2. I pressed Ctrl+Alt+Del. 3. reboot.target was going to be isolated. 4. transaction_apply() proceeded to install a var.mount/stop job. 5. job_install() canceled the conflicting start job. 6. Depending jobs ended recursively with JOB_DEPENDENCY, among them was local-fs.target/start. 7. Its OnFailure action triggered - emergency.target was now going to be isolated. 8. We recursed back into transaction_apply() where the half-installed var.mount/stop job confused us. Recursing from job installation back into the transaction code cannot be a good idea. Avoid the problem by canceling the conflicting job non-recursively in job_install(). I don't think we'll miss anything by not recursing here. After all, we are called from transaction_apply(). We will not be installing just this one job, but all jobs from a transaction. All requirement dependencies will be included in it and will be installed separately. Every transaction job will get a chance to cancel its own conflicting installed job.
2012-10-13log: introduce a macro to format message idZbigniew Jędrzejewski-Szmek
The MESSAGE_ID=... stanza will appear in countless number of places. It is just too long to write it out in full each time. Incidentally, this also fixes a typo of MESSSAGE is three places.
2012-09-03journal: suppress structured messages if they'd go to the consoleLennart Poettering
2012-09-03journal: generate structured journal messages for a number of eventsLennart Poettering
2012-05-14job: info message if JOB_VERIFY_ACTIVE detects an inactive unitMichal Schmidt
2012-05-14job: report the status of first half of JOB_RESTART the same as JOB_STOPMichal Schmidt
2012-05-14unit: unit type dependent status messagesMichal Schmidt
Instead of generic "Starting..." and "Started" messages for all unit use type-dependent messages. For example, mounts will announce "Mounting..." and "Mounted". Add status messages to units of types that used to be entirely silent (automounts, sockets, targets, devices). For unit types whose jobs are instantaneous, report only the job completion, not the starting event. Socket units with non-instantaneous jobs are rare (Exec*= is not used often in socket units), so I chose not to print the starting messages for them either. This will hopefully give people better understanding of the boot.
2012-05-14job: change red [ABORT] status to yellow [DEPEND]Michal Schmidt
The red "[ABORT]" for a dependency failure is too scary. It suggests a crash. And it suggests a problem with the unit itself. Change it to a yellow "[DEPEND]" message. The color communicates the level of seriousness better.
2012-05-14job: only jobs on the runqueue can be runMichal Schmidt
2012-04-25core: add NOP jobs, job type collapsingMichal Schmidt
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
2012-04-23transaction: cancel jobs non-recursively on isolateMichal Schmidt
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
2012-04-24job: serialize jobs properlyMichal Schmidt
Jobs were not preserved correctly over a daemon-reload operation. A systemctl process waiting for a job completion received a job removal signal. The job itself changed its id. The job timeout started ticking all over again. This fixes the deficiencies.
2012-04-22job: the status messages are proper sentences, hence end them with a full stopLennart Poettering
2012-04-20dbus-job: allow multiple bus clientsMichal Schmidt
Merging of jobs can result in more than one client being interested in a job.
2012-04-20transaction: remove checks for installedMichal Schmidt
Transactions cannot contain installed jobs anymore. Remove the now pointless checks.
2012-04-20transaction: rework merging with installed jobsMichal Schmidt
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.
2012-04-20job: separate job_install()Michal Schmidt
Let the jobs install themselves.
2012-04-20transaction: remove the anchor linkMichal Schmidt
tr->anchor_job is sufficient.
2012-04-20job: jobs shouldn't need to know about transaction anchorsMichal Schmidt
Let the transactions maintain their own anchor links.
2012-04-20job: job_new() can find the manager from the unitMichal Schmidt
2012-04-20manager: Transaction as an objectMichal Schmidt
This makes it obvious that transactions are short-lived. They are created in manager_add_job() and destroyed after the application of jobs. It also prepares for a split of the transaction code to a new source.
2012-04-20job: job_uninstall()Michal Schmidt
Split the uninstallation of the job from job_free() into a separate function. Adjust the callers. job_free() now only works on unlinked and uninstalled jobs. This enforces clear thinking about job lifetimes.
2012-04-20job: allow job_free() only on already unlinked jobsMichal Schmidt
job_free() is IMO too helpful when it unlinks the job from the transaction. The callers should ensure the job is already unlinked before freeing. The added assertions check if anyone gets it wrong.
2012-04-13unit: signal explicitly if a condition failed in unit_start()Lennart Poettering
We shouldn't print a status message on the console if we skipped a unit due to a condition. Hence make unit_start() return -ENOEXEC in such a case which is mapped to JOB_SKIPPED which results in no console message.
2012-04-12relicense to LGPLv2.1 (with exceptions)Lennart Poettering
We finally got the OK from all contributors with non-trivial commits to relicense systemd from GPL2+ to LGPL2.1+. Some udev bits continue to be GPL2+ for now, but we are looking into relicensing them too, to allow free copy/paste of all code within systemd. The bits that used to be MIT continue to be MIT. The big benefit of the relicensing is that closed source code may now link against libsystemd-login.so and friends.
2012-04-11move libsystemd_core.la sources into core/Kay Sievers