Commit graph

16790 commits

Author SHA1 Message Date
Tom Gundersen 6d148a842e sd-event: sd_event_prepare - stay in PREPARED if sd_event_wait() indicates that no sources are pending 2014-08-26 00:22:06 +02:00
Tom Gundersen c45a5a7446 sd-event: split run into prepare/wait/dispatch
This will allow sd-event to be integrated into an external event loop, which
in turn will allow (say) glib-based applications to use our various libraries,
without manually integrating each of them (bus, rtnl, dhcp, ...).

The external event-loop should integrate sd-event int he following way:

Every iteration must start with a call to sd_event_prepare(), which will
return 0 if no event sources are ready to be processed, a positive value if
they are and a negative value on error. sd_event_prepare() may only be called
following sd_event_dispatch(); a call to sd_event_wait() indicating that no
sources are ready to be dispatched; or a failed call to sd_event_dispatch() or
sd_event_wait().

A successful call to sd_event_prepare() indicating that no event sources are
ready to be dispatched must be followed by a call to sd_event_wait(),
which will return 0 if it timed out without event sources being ready to
be processed, a negative value on error and a positive value otherwise.
sd_event_wait() may only be called following a successful call to
sd_event_prepare() indicating that no event sources are ready to be dispatched.

If sd_event_wait() indicates that some events sources are ready to be
dispatched, it must be followed by a call to sd_event_dispatch(). This
is the only time sd_event_dispatch() may be called.
2014-08-25 21:52:36 +02:00
Lukas Nykryn 41a451cc29 systemctl: fix broken list-unit-files with --root
This patch modifies unit_file_get_list which will now return
hashmap of structures where f->path is *without* root_dir prefix.

This change should be ok, because current code either does not use
root_dir at all or calls basename() on the f->path.
2014-08-25 15:51:55 +02:00
Lennart Poettering d74f9e8e8a update TODO 2014-08-22 18:10:31 +02:00
Lennart Poettering d81afec1c9 core: split up "starting" manager state into "initializing" and "starting"
We'll stay in "initializing" until basic.target has reached, at which
point we will enter "starting".

This is preparation so that we can change the startip timeout to only
apply to the first phase of startup, not the full procedure.
2014-08-22 18:10:31 +02:00
Lennart Poettering f07756bfe2 core: introduce "poweroff" as new failure action types
Also, change the default action on a system start-up timeout to powering off.
2014-08-22 18:10:31 +02:00
Lennart Poettering c4147df156 resolved: fix typo in log message 2014-08-22 18:10:31 +02:00
Lennart Poettering e12919e8be core: print 'startup finished' messages even if we log to console 2014-08-22 18:10:31 +02:00
Lennart Poettering 2928b0a863 core: add support for a configurable system-wide start-up timeout
When this system-wide start-up timeout is hit we execute one of the
failure actions already implemented for services that fail.

This should not only be useful on embedded devices, but also on laptops
which have the power-button reachable when the lid is closed. This
devices, when in a backpack might get powered on by accident due to the
easily reachable power button. We want to make sure that the system
turns itself off if it starts up due this after a while.

When the system manages to fully start-up logind will suspend the
machine by default if the lid is closed. However, in some cases we don't
even get as far as logind, and the boot hangs much earlier, for example
because we ask for a LUKS password that nobody ever enters.

Yeah, this is a real-life problem on my Yoga 13, which has one of those
easily accessible power buttons, even if the device is closed.
2014-08-22 18:10:31 +02:00
Daniel Mack 2de1851fe3 missing.h: add a cpp warning for __NR_memfd_create on MIPS 2014-08-22 16:10:02 +02:00
Daniel Mack a7d611f280 missing.h: add fake __NR_memfd_create for MIPS
We don't have the correct __NR_memfd_create syscall number yet, so set it to
0xffffffff for now to prevent compile time errors.
2014-08-22 15:41:18 +02:00
David Herrmann 40a1eebde6 shared: add MAXSIZE() and use it in resolved
The MAXSIZE() macro takes two types and returns the size of the larger
one. It is much simpler to use than MAX(sizeof(A), sizeof(B)) and also
avoids any compiler-extensions, unlike CONST_MAX() and MAX() (which are
needed to avoid evaluating arguments more than once). This was suggested
by Daniele Nicolodi <daniele@grinta.net>.

Also make resolved use this macro instead of CONST_MAX(). This enhances
readability quite a bit.
2014-08-22 14:01:05 +02:00
Lennart Poettering 0975b63fb3 dbus1-generator: properly free the FILE*
Also, rework the code to make use of fflush_and_check().

Issue discovered by Simon Danner.
2014-08-22 12:44:17 +02:00
Lennart Poettering 337ce7442a update TODO 2014-08-21 19:12:53 +02:00
Lennart Poettering 4fe1be9ce2 systemctl: in list-unit-files, always show legend, even if we know about no unit files 2014-08-21 19:10:29 +02:00
Lennart Poettering 59ccf93d97 install: simplify usage of _cleanup_ macros 2014-08-21 19:08:30 +02:00
Lennart Poettering 96fb8242cc service: allow services of Type=oneshot that specify no ExecStart= commands
This is useful for services that simply want to run something on
shutdown, but not at bootup. They should only set ExecStop= but leave
ExecStart= unset.
2014-08-21 18:50:42 +02:00
Lennart Poettering 1954ea346d update TODO 2014-08-21 18:01:47 +02:00
Lennart Poettering 21b2ce39d4 service: use the right timeout for stop processes we fork 2014-08-21 18:01:22 +02:00
Lennart Poettering f461c8073d execute: explain in a comment, why close_all_fds() is invoked the second time differently 2014-08-21 17:35:19 +02:00
Lennart Poettering 430e21c2f7 bus: when terminating our bus-actviated services that exit-on-idle send STOPPING=1 via sd_notify()
This should fix a race where a service thatis idle drops its name, and
is immediately requested by another client, which causes dbus-daemon to
ask systemd to activate it again, but since systemd still assumes it is
running it won't do anything.
2014-08-21 17:24:22 +02:00
Lennart Poettering 55cdcbacf7 update TODO 2014-08-21 17:24:21 +02:00
Lennart Poettering af4ec4309e notify: send STOPPING=1 from our daemons 2014-08-21 17:24:21 +02:00
Lennart Poettering 308d72dc1e core: allow informing systemd about service status changes with RELOADING=1 and STOPPING=1 sd_notify() messages 2014-08-21 17:24:21 +02:00
Lennart Poettering 70af4d17da manager: don#t dispatch sd_notify() messages and SIGCHLD multiple times to the same units 2014-08-21 17:24:21 +02:00
Lennart Poettering 55836941ff manager: reuse sockaddr_union instead of redefining our own version of it 2014-08-21 17:24:21 +02:00
Lennart Poettering 28849dbadb service,strv: introduce strv_find_startswith() and make use of it
Unlike strv_find_prefix() the new call will return a pointer to the
suffix of the item we found, instead of the whole item. This is more
closer inline with what startswith() does, and allows us to simplify a
couple of invocations.
2014-08-21 17:24:21 +02:00
Lennart Poettering f49650cee2 service: don't invoke functions at the same time as declaring variables 2014-08-21 17:24:21 +02:00
Lennart Poettering 8bb2d17d2b service: remove some pointless linebreaks, to make things more readable 2014-08-21 17:24:21 +02:00
Lennart Poettering abb4c1cc01 service: asynchronous_close() already checks for negative parameters, no need to duplicate that 2014-08-21 17:24:21 +02:00
Lennart Poettering 4c94096027 core: unify how we generate the prefix string when dumping unit state 2014-08-21 17:24:21 +02:00
Lennart Poettering 5ed1227238 util: make asynchronous_close() really work like an asynchronous version of safe_close()
Save/restore errno, like we do in safe_close(). And don't fork a thread
if the parameter is already negative.
2014-08-21 17:24:21 +02:00
Lennart Poettering a9f85faf43 util: simplify close_nointr() a bit 2014-08-21 17:24:21 +02:00
Lennart Poettering 11adc1aef7 util: change return value of startswith() to non-const
This way we can use it on non-const strings, and don't end up with a
const'ified result.

This is similar to libc's strstr() which also takes a const string but
returns a non-const one.
2014-08-21 17:24:21 +02:00
Lennart Poettering 3fdbc82058 CODING_STYLE: document that we don't break lines at 80ch 2014-08-21 17:24:21 +02:00
Harald Hoyer 730836403a journalctl: add "-t --identifier=STRING" option
This turns journalctl to the counterpart of systemd-cat.
Messages sent with

systemd-cat --identifier foo --prioritiy debug

can now be shown with

journalctl --identifier foo --prioritiy debug

"--identifier" is not merged with "--unit" to make a clear
distinction between syslog and systemd units.
syslog identifiers can be chosen freely by anyone.
2014-08-21 14:16:29 +02:00
Tom Gundersen 9b36454543 sd-event: add API to access epoll_fd
This is a prerequisite for integrating sd-event into an external
event loop.
2014-08-20 17:24:11 +02:00
Tom Gundersen a9feff3d77 resolved: write resolv.conf search - switch arguments
Found by Lukáš Nykrýn.
2014-08-20 15:56:18 +02:00
Lukas Nykryn e1ad6e245d journal-upload: make sure that 'r' is initialized 2014-08-20 15:13:06 +02:00
Lukas Nykryn 081e009bef util: return after freeing all members of array 2014-08-20 15:02:09 +02:00
Lukas Nykryn 7a855149ea journal-remote: remove unreachable code 2014-08-20 14:51:46 +02:00
Lennart Poettering be754d5443 resolved: fix which return codes we check
Discovered by Lukas Nykryn
2014-08-20 14:48:18 +02:00
Lukas Nykryn 03664a6291 resolved-dns-rr: fix typo
a->rrsig.type_covered != a->rrsig.type_covered" is always false
regardless of the values of its operands because those operands are identical.
2014-08-20 14:34:26 +02:00
Lennart Poettering 5dd6d0f8ff machine-id-setup: don't try to read UUID from VM/container manager if we operate on a root directory that's not /
This should make sure no UUID from the host systemd-machine-id-setup is
running on leaks onto a disk image that is provisioned with the tool.
2014-08-20 13:51:17 +02:00
Tom Gundersen 413f6df864 build: remove repeated KMOD section 2014-08-20 11:25:23 +02:00
Lukas Nykryn fdbdf6ec29 systemctl: fail in the case that no unit files were found
Previously systemctl died with message

-bash-4.2# systemctl --root /rawhi list-unit-files
(src/systemctl/systemctl.c:868) Out of memory.

in the case that no unit files were found in the --root
or the directory did not exist.

So lets return ENOENT in the case that --root does not exist
and empty list in the case that there are no unit files.
2014-08-20 10:45:18 +02:00
Lennart Poettering 5d0ae62c66 CONST_MAX breaks gcc on fedora 20 with optimiztation 2014-08-20 00:57:17 +02:00
Lennart Poettering 0340a83b26 build: include more optional modules in build string 2014-08-20 00:47:43 +02:00
Lennart Poettering cccc74971f update hwdb 2014-08-20 00:38:39 +02:00
Lennart Poettering 5364f729ba indentation/spurious whitespace fixes 2014-08-20 00:18:14 +02:00