diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-09-17 18:38:58 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-10-09 14:19:52 +0200 |
commit | d12f698dbb65df1079cc98605c8738aa8224d301 (patch) | |
tree | 14ac299efe395fc4a0d6a78f2e13a595181edd8b /tests | |
parent | eda8b7b23d97994f7e9d1d6554ba4657b6531ad8 (diff) |
logging: Introduce mutex API to manage log_target in multi-thread envs
log_enable_multithread() enables use of locks inside the
implementation. Lock use is disabled by default, this way only
multi-thread processes need to enable it and suffer related
complexity/performance penalties.
Locks are required around osmo_log_target_list and items inside it,
since targets can be used, modified and deleted by different threads
concurrently (for instance, user writing "logging disable" in VTY while
another thread is willing to write into that target).
Multithread apps and libraries aiming at being used in multithread apps
should update their code to use the locks introduced here when
containing code iterating over osmo_log_target_list explictly or
implicitly by obtaining a log_target (eg. osmo_log_vty2tgt()).
Related: OS#4088
Change-Id: Id7711893b34263baacac6caf4d489467053131bb
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 4 | ||||
-rw-r--r-- | tests/logging/logging_vty_test.c | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index ececf69c..e0993b16 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -AM_CFLAGS = -Wall $(TALLOC_CFLAGS) +AM_CFLAGS = -Wall $(TALLOC_CFLAGS) $(PTHREAD_CFLAGS) AM_LDFLAGS = -no-install -LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) +LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) $(PTHREAD_LIBS) if ENABLE_SERCOM_STUB noinst_LIBRARIES = libsercomstub.a diff --git a/tests/logging/logging_vty_test.c b/tests/logging/logging_vty_test.c index 30426f39..e7019f61 100644 --- a/tests/logging/logging_vty_test.c +++ b/tests/logging/logging_vty_test.c @@ -241,6 +241,7 @@ int main(int argc, char **argv) vty_init(&vty_info); osmo_init_logging2(root_ctx, &log_info); + log_enable_multithread(); vty_commands_init(); |