Don't allow capturing from multiple interface when compiled with multiple thread
authortuexen <tuexen@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 16 Jul 2011 11:07:32 +0000 (11:07 +0000)
committertuexen <tuexen@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 16 Jul 2011 11:07:32 +0000 (11:07 +0000)
support.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@38057 f5534014-38df-0310-8fa8-9805f1628bb7

gtk/capture_dlg.c
gtk/capture_if_dlg.c
gtk/main.c
gtk/main_welcome.c

index 43ee6a701970c29ed3df73df781ecb3e9662bf32..de3e5b7869b673b5aa2a48d362d50685e71a0f5f 100644 (file)
@@ -2706,6 +2706,13 @@ capture_start_cb(GtkWidget *w _U_, gpointer d _U_)
       return;   /* error in options dialog */
   }
 
+#ifndef USE_THREADS
+  if (global_capture_opts.ifaces->len > 1) {
+      simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+        "You specified multiple interfaces for capturing which this version of Wireshark doesn't support.");
+    return;
+  }
+#endif
   if (global_capture_opts.ifaces->len == 0) {
     if (prefs.capture_device == NULL) {
       simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
index dd48920ea908d935b0adf082fa3a375ce4b9f150..3871376e9c074bf8345351084f5438eb9b61e6c3 100644 (file)
@@ -158,7 +158,11 @@ store_selected(GtkWidget *choose_bt _U_, gpointer if_data)
     }
   }
   if (cap_if_w) {
+#ifdef USE_THREADS
     gtk_widget_set_sensitive(capture_bt, !gbl_capture_in_progress && (currently_selected > 0));
+#else
+    gtk_widget_set_sensitive(capture_bt, !gbl_capture_in_progress && (currently_selected == 1));
+#endif
     gtk_widget_set_sensitive(options_bt, !gbl_capture_in_progress && (currently_selected <= 1));
   }
 }
@@ -237,7 +241,7 @@ capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data _U_)
     global_capture_opts.save_file = NULL;
   }
 
-  if (global_capture_opts.ifaces->len >= 2) {
+  if (global_capture_opts.ifaces->len > 1) {
     global_capture_opts.use_pcapng = TRUE;
   }
   /* stop capturing from all interfaces, we are going to do real work now ... */
@@ -306,7 +310,7 @@ capture_prepare_cb(GtkWidget *prepare_bt _U_, gpointer if_data _U_)
   }
   /* stop capturing from all interfaces, we are going to do real work now ... */
   window_destroy(cap_if_w);
-  if (global_capture_opts.ifaces->len >= 2) {
+  if (global_capture_opts.ifaces->len > 1) {
     global_capture_opts.use_pcapng = TRUE;
   }
   capture_prep_cb(NULL, NULL);
@@ -389,7 +393,11 @@ set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress)
   gbl_capture_in_progress = capture_in_progress;
   if (cap_if_w) {
     gtk_widget_set_sensitive(stop_bt, capture_in_progress);
+#ifdef USE_THREADS
     gtk_widget_set_sensitive(capture_bt, !capture_in_progress && (currently_selected > 0));
+#else
+    gtk_widget_set_sensitive(capture_bt, !capture_in_progress && (currently_selected == 1));
+#endif
     gtk_widget_set_sensitive(options_bt, !capture_in_progress && (currently_selected <= 1));
   }
 }
index b969ae51995db968086245b4c8b33926da2778f6..1e5937daafa82952b47c4b320cb2ebb0e877528c 100644 (file)
@@ -2762,6 +2762,12 @@ main(int argc, char *argv[])
   prefs_apply_all();
 
 #ifdef HAVE_LIBPCAP
+#ifndef USE_THREADS
+  if ((global_capture_opts.ifaces->len > 0) && start_capture) {
+    cmdarg_err("You specified multiple interfaces for capturing which this version of Wireshark doesn't support.");
+    exit(2);
+  }
+#endif
   if ((global_capture_opts.ifaces->len == 0) &&
       (prefs.capture_device != NULL)) {
     interface_options interface_opts;
@@ -2992,8 +2998,7 @@ main(int argc, char *argv[])
            one of MATE's late-registered fields as part of the filter. */
         start_requested_stats();
       }
-    }
-    else {
+    } else {
       show_main_window(FALSE);
       check_and_warn_user_startup(cf_name);
       set_menus_for_capture_in_progress(FALSE);
index 9a0be9ba651b723872169218c25101ca633e1876..393c267bed6421615bd005e2f7353c828f0cca4b 100644 (file)
@@ -873,11 +873,18 @@ static void capture_if_start(GtkWidget *w _U_, gpointer data _U_)
   view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
   entry = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
   len = gtk_tree_selection_count_selected_rows(entry);
-  if (!entry || len==0) {
+  if (!entry || len == 0) {
     simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
       "You didn't specify an interface on which to capture packets.");
     return;
   }
+#ifndef USE_THREADS
+  if (len > 1) {
+    simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+      "You specified multiple interfaces for capturing which this version of Wireshark doesn't support.");
+    return;
+  }
+#endif
   while (global_capture_opts.ifaces->len > 0) {
     interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, 0);
     global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, 0);
@@ -1051,11 +1058,19 @@ welcome_new(void)
         gtk_tree_view_column_set_visible(column, FALSE);
         selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(if_view));
         gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
+#ifdef USE_THREADS
         item_hb = welcome_button(WIRESHARK_STOCK_CAPTURE_START,
             "Start",
             "Choose one or more interfaces to capture from, then <b>Start</b>",
             "Same as Capture/Interfaces with default options",
             (welcome_button_callback_t)capture_if_start, (gpointer)if_view);
+#else
+        item_hb = welcome_button(WIRESHARK_STOCK_CAPTURE_START,
+            "Start",
+            "Choose exactly one interface to capture from, then <b>Start</b>",
+            "Same as Capture/Interfaces with default options",
+            (welcome_button_callback_t)capture_if_start, (gpointer)if_view);
+#endif
         gtk_box_pack_start(GTK_BOX(topic_to_fill), item_hb, FALSE, FALSE, 5);
         welcome_if_tree_load();
         gtk_container_add (GTK_CONTAINER (swindow), if_view);