chiark / gitweb /
journal: guarantee async-signal-safety in sd_journald_sendv
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 26 Jan 2014 04:35:28 +0000 (23:35 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 28 Jan 2014 04:17:02 +0000 (23:17 -0500)
commit65b3903ff576488eaabb51d3c4fbf9c73d867d7c
tree0343e9d79057f6ca67acb87d6cc06f45ab7a1384
parent8e33886ec582336564ae11b80023abe93d7599c0
journal: guarantee async-signal-safety in sd_journald_sendv

signal(7) provides a list of functions which may be called from a
signal handler. Other functions, which only call those functions and
don't access global memory and are reentrant are also safe.
sd_j_sendv was mostly OK, but would call mkostemp and writev in a
fallback path, which are unsafe.

Being able to call sd_j_sendv in a async-signal-safe way is important
because it allows it be used in signal handlers.

Safety is achieved by replacing mkostemp with open(O_TMPFILE) and an
open-coded writev replacement which uses write. Unfortunately,
O_TMPFILE is only available on kernels >= 3.11. When O_TMPFILE is
unavailable, an open-coded mkostemp is used.

https://bugzilla.gnome.org/show_bug.cgi?id=722889
.gitignore
Makefile.am
man/sd_journal_print.xml
src/journal/journal-send.c
src/shared/def.h
src/shared/missing.h
src/shared/util.c
src/shared/util.h
src/test/test-tmpfiles.c [new file with mode: 0644]
src/test/test-util.c