diff options
author | gerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-11-09 23:43:50 +0000 |
---|---|---|
committer | gerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-11-09 23:43:50 +0000 |
commit | c7d5a6720d84c0571e08f1de212b2d61bcd9bdc1 (patch) | |
tree | 94d5184e90d9548291480b0a6d94ec8898862d6d | |
parent | b9d2890bf6df0904f506dfa73ec4a3058cebeef6 (diff) |
Try to fix the GLib thread API deprecations listed in bug 6552.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@39776 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r-- | dumpcap.c | 12 | ||||
-rw-r--r-- | gtk/capture_dlg.c | 22 | ||||
-rw-r--r-- | gtk/main.c | 2 | ||||
-rw-r--r-- | gtk/main_welcome.c | 12 | ||||
-rw-r--r-- | tshark.c | 16 |
5 files changed, 52 insertions, 12 deletions
@@ -2298,7 +2298,12 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld, pcap_opts->cap_pipe_state = 0; pcap_opts->cap_pipe_err = PIPOK; #ifdef _WIN32 +#if GLIB_CHECK_VERSION(2,31,0) + pcap_opts->cap_pipe_read_mtx = g_malloc(sizeof(GMutex)); + g_mutex_init(pcap_opts->cap_pipe_read_mtx); +#else pcap_opts->cap_pipe_read_mtx = g_mutex_new(); +#endif pcap_opts->cap_pipe_pending_q = g_async_queue_new(); pcap_opts->cap_pipe_done_q = g_async_queue_new(); #endif @@ -3189,7 +3194,12 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_queue_packets = 0; for (i = 0; i < global_ld.pcaps->len; i++) { pcap_opts = g_array_index(global_ld.pcaps, pcap_options *, i); +#if GLIB_CHECK_VERSION(2,31,0) + /* XXX - Add an interface name here? */ + pcap_opts->tid = g_thread_new("Capture read", pcap_read_handler, pcap_opts); +#else pcap_opts->tid = g_thread_create(pcap_read_handler, pcap_opts, TRUE, NULL); +#endif } } while (global_ld.go) { @@ -3848,8 +3858,10 @@ main(int argc, char *argv[]) /* Initialize the pcaps list */ global_ld.pcaps = g_array_new(FALSE, FALSE, sizeof(pcap_options *)); +#if !GLIB_CHECK_VERSION(2,31,0) /* Initialize the thread system */ g_thread_init(NULL); +#endif #ifdef _WIN32 /* Load wpcap if possible. Do this before collecting the run-time version information */ diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c index ded8a320f5..1a14417793 100644 --- a/gtk/capture_dlg.c +++ b/gtk/capture_dlg.c @@ -293,10 +293,9 @@ typedef struct capture_filter_check { /* We could make this smarter by caching results */ capture_filter_check_t cfc_data; -GMutex *pcap_compile_mtx = NULL; -GCond *cfc_data_cond = NULL; -GMutex *cfc_data_mtx = NULL; -GThread *cfc_thread = NULL; +static GMutex *pcap_compile_mtx; +static GCond *cfc_data_cond; +static GMutex *cfc_data_mtx; #if 0 #define DEBUG_SYNTAX_CHECK(state1, state2) g_warning("CF state %s -> %s : %s", state1, state2, cfc_data.filter_text) @@ -317,6 +316,7 @@ check_capture_filter_syntax(void *data _U_) { } cfc_data.state = CFC_UNKNOWN; DEBUG_SYNTAX_CHECK("pending", "unknown"); + g_mutex_unlock(cfc_data_mtx); g_mutex_lock(pcap_compile_mtx); @@ -379,11 +379,23 @@ void capture_filter_init(void) { cfc_data.filter_text = NULL; cfc_data.filter_te = NULL; cfc_data.state = CFC_PENDING; + +#if GLIB_CHECK_VERSION(2,31,0) + pcap_compile_mtx = g_malloc(sizeof(GMutex)); + g_mutex_init(pcap_compile_mtx); + cfc_data_cond = g_malloc(sizeof(GCond)); + g_cond_init(cfc_data_cond); + cfc_data_mtx = g_malloc(sizeof(GMutex)); + g_mutex_init(cfc_data_mtx); + g_thread_new("Capture filter syntax", check_capture_filter_syntax, NULL); +#else pcap_compile_mtx = g_mutex_new(); cfc_data_cond = g_cond_new(); cfc_data_mtx = g_mutex_new(); - g_timeout_add(200, update_capture_filter_te, NULL); g_thread_create(check_capture_filter_syntax, NULL, FALSE, NULL); +#endif + + g_timeout_add(200, update_capture_filter_te, NULL); } static void diff --git a/gtk/main.c b/gtk/main.c index 0caf80323d..de8c562a86 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -2316,7 +2316,9 @@ main(int argc, char *argv[]) optind = optind_initial; opterr = 1; +#if !GLIB_CHECK_VERSION(2,31,0) g_thread_init(NULL); +#endif /* Set the current locale according to the program environment. * We haven't localized anything, but some GTK widgets are localized diff --git a/gtk/main_welcome.c b/gtk/main_welcome.c index c78457102a..fc11ca83ed 100644 --- a/gtk/main_welcome.c +++ b/gtk/main_welcome.c @@ -111,7 +111,7 @@ static GArray *interfaces = NULL; static GSList *status_messages = NULL; -static GMutex *recent_mtx = NULL; +static GMutex *recent_mtx; /* The "scroll box dynamic" is a (complicated) pseudo widget to */ /* place a vertically list of widgets in (currently the interfaces and recent files). */ @@ -630,7 +630,12 @@ welcome_filename_link_new(const gchar *filename, GtkWidget **label, GObject *men g_signal_connect(w, "destroy", G_CALLBACK(welcome_filename_destroy_cb), ri_stat); g_free(str_escaped); +#if GLIB_CHECK_VERSION(2,31,0) + /* XXX - Add the filename here? */ + g_thread_new("Recent item status", get_recent_item_status, ri_stat); +#else g_thread_create(get_recent_item_status, ri_stat, FALSE, NULL); +#endif ri_stat->timer = g_timeout_add(200, update_recent_items, ri_stat); /* event box */ @@ -1382,7 +1387,12 @@ welcome_new(void) welcome_eb); gtk_widget_show_all(welcome_scrollw); +#if GLIB_CHECK_VERSION(2,31,0) + recent_mtx = g_malloc(sizeof(GMutex)); + g_mutex_init(&recent_mtx); +#else recent_mtx = g_mutex_new(); +#endif return welcome_scrollw; } @@ -1888,7 +1888,7 @@ typedef struct pipe_input_tag { pipe_input_cb_t input_cb; guint pipe_input_id; #ifdef _WIN32 - GStaticMutex callback_running; + GMutex *callback_running; #endif } pipe_input_t; @@ -1907,8 +1907,7 @@ pipe_timer_cb(gpointer data) pipe_input_t *pipe_input_p = data; gint iterations = 0; - - g_static_mutex_lock (&pipe_input_p->callback_running); + g_mutex_lock (pipe_input_p->callback_running); /* try to read data from the pipe only 5 times, to avoid blocking */ while(iterations < 5) { @@ -1934,7 +1933,7 @@ pipe_timer_cb(gpointer data) if (!pipe_input_p->input_cb(pipe_input_p->source, pipe_input_p->user_data)) { g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: input pipe closed, iterations: %u", iterations); /* pipe closed, return false so that the timer is stopped */ - g_static_mutex_unlock (&pipe_input_p->callback_running); + g_mutex_unlock (pipe_input_p->callback_running); return FALSE; } } @@ -1949,7 +1948,7 @@ pipe_timer_cb(gpointer data) /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: finished with iterations: %u, new timer", iterations);*/ - g_static_mutex_unlock (&pipe_input_p->callback_running); + g_mutex_unlock (pipe_input_p->callback_running); /* we didn't stopped the timer, so let it run */ return TRUE; @@ -1967,7 +1966,12 @@ pipe_input_set_handler(gint source, gpointer user_data, int *child_process, pipe pipe_input.input_cb = input_cb; #ifdef _WIN32 - g_static_mutex_init(&pipe_input.callback_running); +#if GLIB_CHECK_VERSION(2,31,0) + pipe_input.callback_running = g_malloc(sizeof(GMutex)); + g_mutex_init(pipe_input.callback_running); +#else + pipe_input.callback_running = g_mutex_new(); +#endif /* Tricky to use pipes in win9x, as no concept of wait. NT can do this but that doesn't cover all win32 platforms. GTK can do this but doesn't seem to work over processes. Attempt to do |