fix: liblttng-ust-fd async-signal-safe close()
authorMichael Jeanson <mjeanson@efficios.com>
Tue, 9 Mar 2021 17:38:06 +0000 (12:38 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 9 Dec 2021 16:13:02 +0000 (11:13 -0500)
commit5ce8eb6d442bddf34a6e5615c20cfc20438dc25d
tree38fb8e5bb0d1d8e10b3dfea0840158c7c5ebc792
parent2af952211343a85341a390e1b7a000aec3b075b5
fix: liblttng-ust-fd async-signal-safe close()

"close(2)" is documented as async-signal-safe (see signal-safety(7)) and
as such our override function should also be. This means we shouldn't do
lazy initialization of the function pointer to the original libc close
symbol in the override function.

If we move the initialization of the function pointer in the library
constructor we risk breaking other constructors that may run before ours
and call close().

A compromise is to explicitly do the initialization in the constructor
but keep a lazy init scheme if close() is called before it is executed.

The dlsym call is now done only once, if it fails the wrappers will
return -1 and set errno to ENOSYS.

Change-Id: I05c66d2f5d51b2022c6803ca215340fb9c00f5a8
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/lib/lttng-ust-fd/lttng-ust-fd.c
This page took 0.025437 seconds and 4 git commands to generate.