forked from osmocom/wireshark
Fix build and thread runtime compat with older GLib
CentOS 6 ships with glib 2.28.8 which do not support g_ptr_array_new_full (make-taps/make-dissectors) and need to link with wsutil for glib-compat. g_thread_new was only introduced with GLib 2.32 (not 2.31), so adjust the check accordingly. Abort in case thread creation fails (as documented). Properly initialize threads or it will abort on runtime (this also requires linking epan with gthreads in CMake, autotools already includes it with GLIB_LIBS). Change-Id: Ie81d6df7b3b26aaa4eb25e23719a220755e2c13c Reviewed-on: https://code.wireshark.org/review/24978 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
8642d72f36
commit
bad83f249f
|
@ -120,6 +120,9 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* for g_thread_new */
|
||||
#include "wsutil/glib-compat.h"
|
||||
|
||||
#ifdef DEBUG_CHILD_DUMPCAP
|
||||
FILE *debug_log; /* for logging debug messages to */
|
||||
/* a file if DEBUG_CHILD_DUMPCAP */
|
||||
|
@ -2044,11 +2047,7 @@ pcapng_pipe_open_live(int fd,
|
|||
}
|
||||
#ifdef _WIN32
|
||||
else {
|
||||
#if GLIB_CHECK_VERSION(2,31,0)
|
||||
g_thread_new("cap_pipe_open_live", &cap_thread_read, pcap_src);
|
||||
#else
|
||||
g_thread_create(&cap_thread_read, pcap_src, FALSE, NULL);
|
||||
#endif
|
||||
|
||||
bh->block_type = type;
|
||||
pcap_src->cap_pipe_buf = (char *) &bh->block_total_length;
|
||||
|
|
|
@ -282,6 +282,7 @@ set(epan_LIBS
|
|||
${GCRYPT_LIBRARIES}
|
||||
${GEOIP_LIBRARIES}
|
||||
${GLIB2_LIBRARIES}
|
||||
${GTHREAD2_LIBRARIES}
|
||||
${GNUTLS_LIBRARIES}
|
||||
${KERBEROS_LIBRARIES}
|
||||
${LUA_LIBRARIES}
|
||||
|
|
|
@ -1865,7 +1865,8 @@ set(ALL_DISSECTOR_SRC
|
|||
)
|
||||
|
||||
add_executable(make-dissectors make-dissectors.c)
|
||||
target_link_libraries(make-dissectors ${GLIB2_LIBRARIES})
|
||||
# wsutil is only required for glib-compat.c
|
||||
target_link_libraries(make-dissectors ${GLIB2_LIBRARIES} wsutil)
|
||||
|
||||
#
|
||||
# We pass the arguments to make-dissectors in a file to avoid limitations
|
||||
|
|
|
@ -554,7 +554,7 @@ register_gameserv_addr(struct tibia_convo *convo, guint32 ipaddr, guint16 port)
|
|||
alloc_address_wmem(NULL, &entry->addr, AT_IPv4, sizeof ipaddr, &ipaddr);
|
||||
entry->port = port;
|
||||
entry->privkey = NULL;
|
||||
if (!g_hash_table_contains(rsakeys, entry)) {
|
||||
if (g_hash_table_lookup(rsakeys, entry) == NULL) {
|
||||
entry->privkey = convo->privkey;
|
||||
g_hash_table_insert(rsakeys, entry, entry->privkey);
|
||||
} else {
|
||||
|
|
14
epan/epan.c
14
epan/epan.c
|
@ -191,6 +191,20 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da
|
|||
{
|
||||
volatile gboolean status = TRUE;
|
||||
|
||||
/*
|
||||
* proto_init -> register_all_protocols -> g_async_queue_new which
|
||||
* requires threads to be initialized. This happens automatically with
|
||||
* GLib 2.32, before that g_thread_init must be called. But only since
|
||||
* GLib 2.24, multiple invocations are allowed. Check for an earlier
|
||||
* invocation just in case.
|
||||
*/
|
||||
#if !GLIB_CHECK_VERSION(2,31,0)
|
||||
# if !GLIB_CHECK_VERSION(2,24,0)
|
||||
if (!g_thread_get_initialized())
|
||||
# endif
|
||||
g_thread_init(NULL);
|
||||
#endif
|
||||
|
||||
/* initialize memory allocation subsystem */
|
||||
wmem_init();
|
||||
|
||||
|
|
|
@ -97,7 +97,8 @@ set_target_properties(ui PROPERTIES
|
|||
)
|
||||
|
||||
add_executable(make-taps make-taps.c)
|
||||
target_link_libraries(make-taps ${GLIB2_LIBRARIES})
|
||||
# wsutil is only required for glib-compat.c
|
||||
target_link_libraries(make-taps ${GLIB2_LIBRARIES} wsutil)
|
||||
|
||||
if (HTML_HELP_COMPILER)
|
||||
add_definitions(-DHHC_DIR)
|
||||
|
|
|
@ -120,9 +120,17 @@ g_async_queue_timeout_pop(GAsyncQueue *queue,
|
|||
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2,31,0)
|
||||
GThread *g_thread_new(const gchar *name _U_, GThreadFunc func, gpointer data)
|
||||
GThread *g_thread_new(const gchar *name, GThreadFunc func, gpointer data)
|
||||
{
|
||||
return g_thread_create(func, data, TRUE, NULL);
|
||||
GError *error = NULL;
|
||||
GThread *thread;
|
||||
|
||||
thread = g_thread_create(func, data, TRUE, &error);
|
||||
|
||||
if G_UNLIKELY (thread == NULL)
|
||||
g_error ("creating thread '%s': %s", name ? name : "", error->message);
|
||||
|
||||
return thread;
|
||||
}
|
||||
#endif /* GLIB_CHECK_VERSION(2,31,0)*/
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ WS_DLL_PUBLIC GPtrArray* g_ptr_array_new_full(guint reserved_size, GDestroyNotif
|
|||
WS_DLL_PUBLIC gpointer g_async_queue_timeout_pop(GAsyncQueue *queue, guint64 timeout);
|
||||
#endif /* !GLIB_CHECK_VERSION(2,31,18) */
|
||||
|
||||
// joinable = TRUE, error = NULL
|
||||
#if !GLIB_CHECK_VERSION(2,31,0)
|
||||
WS_DLL_PUBLIC GThread *g_thread_new (const gchar *name, GThreadFunc func, gpointer data);
|
||||
#endif /* !GLIB_CHECK_VERSION(2,31,0) */
|
||||
|
|
Loading…
Reference in New Issue