stewartsmith / libeatmydata

libeatmydata - because fsync() should be a no-op
https://www.flamingspork.com/projects/libeatmydata/
GNU General Public License v3.0
409 stars 21 forks source link

Make initialization thread-safe, and support early callers #19

Closed mapreri closed 3 years ago

mapreri commented 4 years ago

The current initialization code is not thread-safe, and assumes that the only possible caller of open() before initialization completes is dlsym(), which is not the case if there are other preloaded libraries.

This patch makes the initialization thread-safe by using thread-local variables, and adjusts the recursive checking logic to support early callers.

See Debian bug #918520 for more background: https://bugs.debian.org/918520

Signed-off-by: Mattia Rizzolo mattia@debian.org

mapreri commented 4 years ago

Note though that this requires c11 for _Thread_local.

stewartsmith commented 3 years ago

Well, that's interesting! Merged in at 9159bc125bfb8989a5dbc2ce103312c2aa8906f5 and in v129. Thanks!