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:12:12 +0000 (11:12 -0500)
commit5804876495751c1e7785be01af45a7203af13fa3
tree915e8436118d90d8949f5eff6f1120959eec2c7f
parent8041f6416269020f2213ff6be584610c53986c32
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.024487 seconds and 4 git commands to generate.