forked from osmocom/wireshark
Revert "Don't use static GMutexes."
This reverts commit ba3f29b62f
.
Our minimum Glib level now supports this.
Change-Id: I55a783b7aaa1ebfce8f2870d0c24768029ced39e
Reviewed-on: https://code.wireshark.org/review/26838
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
9d49b1258f
commit
18f2b9fd2a
|
@ -18,15 +18,15 @@
|
||||||
static const char *cur_cb_name = NULL;
|
static const char *cur_cb_name = NULL;
|
||||||
// We could use g_atomic_pointer_set/get instead of a mutex, but that's
|
// We could use g_atomic_pointer_set/get instead of a mutex, but that's
|
||||||
// currently (early 2018) invisible to TSAN.
|
// currently (early 2018) invisible to TSAN.
|
||||||
static GMutex *cur_cb_name_mtx;
|
static GMutex cur_cb_name_mtx;
|
||||||
static GAsyncQueue *register_cb_done_q;
|
static GAsyncQueue *register_cb_done_q;
|
||||||
|
|
||||||
#define CB_WAIT_TIME (150 * 1000) // microseconds
|
#define CB_WAIT_TIME (150 * 1000) // microseconds
|
||||||
|
|
||||||
static void set_cb_name(const char *proto) {
|
static void set_cb_name(const char *proto) {
|
||||||
g_mutex_lock(cur_cb_name_mtx);
|
g_mutex_lock(&cur_cb_name_mtx);
|
||||||
cur_cb_name = proto;
|
cur_cb_name = proto;
|
||||||
g_mutex_unlock(cur_cb_name_mtx);
|
g_mutex_unlock(&cur_cb_name_mtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
@ -49,18 +49,11 @@ register_all_protocols(register_cb cb, gpointer cb_data)
|
||||||
gboolean called_back = FALSE;
|
gboolean called_back = FALSE;
|
||||||
GThread *rapw_thread;
|
GThread *rapw_thread;
|
||||||
|
|
||||||
#if GLIB_CHECK_VERSION(2,32,0)
|
|
||||||
cur_cb_name_mtx = (GMutex *)g_malloc(sizeof(GMutex));
|
|
||||||
g_mutex_init(cur_cb_name_mtx);
|
|
||||||
#else
|
|
||||||
cur_cb_name_mtx = g_mutex_new();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rapw_thread = g_thread_new("register_all_protocols_worker", ®ister_all_protocols_worker, NULL);
|
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)) {
|
while (!g_async_queue_timeout_pop(register_cb_done_q, CB_WAIT_TIME)) {
|
||||||
g_mutex_lock(cur_cb_name_mtx);
|
g_mutex_lock(&cur_cb_name_mtx);
|
||||||
cb_name = cur_cb_name;
|
cb_name = cur_cb_name;
|
||||||
g_mutex_unlock(cur_cb_name_mtx);
|
g_mutex_unlock(&cur_cb_name_mtx);
|
||||||
if (cb && cb_name) {
|
if (cb && cb_name) {
|
||||||
cb(RA_REGISTER, cb_name, cb_data);
|
cb(RA_REGISTER, cb_name, cb_data);
|
||||||
called_back = TRUE;
|
called_back = TRUE;
|
||||||
|
@ -94,9 +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);
|
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)) {
|
while (!g_async_queue_timeout_pop(register_cb_done_q, CB_WAIT_TIME)) {
|
||||||
g_mutex_lock(cur_cb_name_mtx);
|
g_mutex_lock(&cur_cb_name_mtx);
|
||||||
cb_name = cur_cb_name;
|
cb_name = cur_cb_name;
|
||||||
g_mutex_unlock(cur_cb_name_mtx);
|
g_mutex_unlock(&cur_cb_name_mtx);
|
||||||
if (cb && cb_name) {
|
if (cb && cb_name) {
|
||||||
cb(RA_HANDOFF, cb_name, cb_data);
|
cb(RA_HANDOFF, cb_name, cb_data);
|
||||||
called_back = TRUE;
|
called_back = TRUE;
|
||||||
|
@ -107,13 +100,6 @@ register_all_protocol_handoffs(register_cb cb, gpointer cb_data)
|
||||||
cb(RA_HANDOFF, "finished", cb_data);
|
cb(RA_HANDOFF, "finished", cb_data);
|
||||||
}
|
}
|
||||||
g_async_queue_unref(register_cb_done_q);
|
g_async_queue_unref(register_cb_done_q);
|
||||||
|
|
||||||
#if GLIB_CHECK_VERSION(2,32,0)
|
|
||||||
g_free(cur_cb_name_mtx);
|
|
||||||
#else
|
|
||||||
g_mutex_free(cur_cb_name_mtx);
|
|
||||||
#endif
|
|
||||||
cur_cb_name_mtx = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gulong register_count(void)
|
gulong register_count(void)
|
||||||
|
|
Loading…
Reference in New Issue