Try to fix the GLib thread API deprecations listed in bug 6552.
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 9 Nov 2011 23:43:50 +0000 (23:43 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 9 Nov 2011 23:43:50 +0000 (23:43 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@39776 f5534014-38df-0310-8fa8-9805f1628bb7

dumpcap.c
gtk/capture_dlg.c
gtk/main.c
gtk/main_welcome.c
tshark.c

index e7b5980c14da73ab8c63d89beeaa522d283b63ee..df758a4e0046881a6168953a8e0170bfee117483 100644 (file)
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -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 */
index ded8a320f53a010525046a415a29a3a83b38d89a..1a14417793990e880510db50f672465028a484ca 100644 (file)
@@ -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
index 0caf80323d01a77f2b237d8898a7c140dfd83878..de8c562a86b9366d11922df801bfc6bc8bf645f5 100644 (file)
@@ -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
index c78457102a3a35b2f92dfc5cc0c295f863366d9e..fc11ca83ed441cfead5c4744812c3037255296ac 100644 (file)
@@ -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;
 }
index 1697fd8f737c63717c94235d4c426cb1893ded0e..e5c7d3436d8660e919bdad05b9e9308e249be86c 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -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