diff options
author | Gerald Combs <gerald@wireshark.org> | 2018-01-07 09:30:04 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2018-01-08 16:38:29 +0000 |
commit | 15746e5922159265468e3d5d19b2feb7b769a57a (patch) | |
tree | d473c43bb4fd4936b61cbb7a2bfa76f4045a8d4d /epan/register.c | |
parent | 7a19320df18adae30d974949f20cbae976b4b0ed (diff) |
Add a mutex for the protocol registration callback name.
Fixes TSAN warnings on macOS.
Change-Id: I6cef7b49874011fd2da2c8dd15b59ce2ae08537a
Reviewed-on: https://code.wireshark.org/review/25185
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'epan/register.c')
-rw-r--r-- | epan/register.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/epan/register.c b/epan/register.c index 460913cf0d..d655e64eb6 100644 --- a/epan/register.c +++ b/epan/register.c @@ -16,12 +16,17 @@ #include "epan/dissectors/dissectors.h" static const char *cur_cb_name = NULL; +// We could use g_atomic_pointer_set/get instead of a mutex, but that's +// currently (early 2018) invisible to TSAN. +static GMutex cur_cb_name_mtx; static GAsyncQueue *register_cb_done_q; #define CB_WAIT_TIME (150 * 1000) // microseconds static void set_cb_name(const char *proto) { + g_mutex_lock(&cur_cb_name_mtx); cur_cb_name = proto; + g_mutex_unlock(&cur_cb_name_mtx); } static void * @@ -46,7 +51,9 @@ register_all_protocols(register_cb cb, gpointer cb_data) rapw_thread = g_thread_new("register_all_protocols_worker", ®ister_all_protocols_worker, NULL); while (!g_async_queue_timeout_pop(register_cb_done_q, CB_WAIT_TIME)) { + g_mutex_lock(&cur_cb_name_mtx); cb_name = cur_cb_name; + g_mutex_unlock(&cur_cb_name_mtx); if (cb && cb_name) { cb(RA_REGISTER, cb_name, cb_data); called_back = TRUE; @@ -80,7 +87,9 @@ register_all_protocol_handoffs(register_cb cb, gpointer cb_data) raphw_thread = g_thread_new("register_all_protocol_handoffs_worker", ®ister_all_protocol_handoffs_worker, NULL); while (!g_async_queue_timeout_pop(register_cb_done_q, CB_WAIT_TIME)) { + g_mutex_lock(&cur_cb_name_mtx); cb_name = cur_cb_name; + g_mutex_unlock(&cur_cb_name_mtx); if (cb && cb_name) { cb(RA_HANDOFF, cb_name, cb_data); called_back = TRUE; |