]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit - configure
libcom_err: Use sem_post/sem_init to prevent race conditions
authorTheodore Ts'o <tytso@mit.edu>
Fri, 12 Sep 2008 14:15:26 +0000 (10:15 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 12 Sep 2008 14:15:26 +0000 (10:15 -0400)
commitd7f45af802330a0e1450afa05185d3722e77a76c
tree4eb79fcc0ad80db68625e7412866c7d400e09402
parent3218dc9db8fc2affeae2fb563db0fc07a55a59de
libcom_err: Use sem_post/sem_init to prevent race conditions

SuSE has been carrying a patch for a long time to prevent a largely
theoretical race condition if a multi-threaded application adds and
removes error tables in multiple threads.  Unfortunately SuSE's
approach breaks compatibility by forcing applications to link and
compile with the -pthread option; using pthread mutexes has
historically been problematic.

This commit fixes things in a more portable way by using
sem_post/sem_wait instead, which is an older interface that doesn't
require the pthreads library.  Linux happens to implement
sem_post/sem_init using futexes, and -lrt ends up pulling in
-lpthread, but the advantage of using POSIX semaphores is that
applications don't have to be built using -pthread, unlike the use of
pthread mutexes.

The add_error_table() and remove_error_table() interfaces are the
preferred interfaces and locking protection have been added to only
these interfaces.  I have not added locking protection to the
generated initialize_xxx_error_table and initialize_xxx_error_table_r
interfaces, to avoid adding symbol dependencies that would cause a
library to fail to work when linking against older com_err libraries
that do not export et_list_lock() and et_list_unlock().  Threaded
applications shouldn't be using these interfaces in any case.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
MCONFIG.in
configure
configure.in
debian/libcomerr2.symbols
lib/et/Makefile.in
lib/et/com_err.pc.in
lib/et/error_message.c