From Mike Garratt:

Friendly Names support causing unnecessary delay when Wireshark starts.

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8034

svn path=/trunk/; revision=49752
This commit is contained in:
Anders Broman 2013-06-04 04:36:19 +00:00
parent ee109cc7b2
commit 78e334b845
5 changed files with 68 additions and 5 deletions

View File

@ -114,6 +114,7 @@ capture_opts_init(capture_options *capture_opts)
capture_opts->autostop_duration = 60; /* 1 min */
capture_opts->output_to_pipe = FALSE;
capture_opts->capture_child = FALSE;
}
@ -488,6 +489,11 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str
interface_opts.console_display_name = g_strdup(if_info->name);
}
free_interface_list(if_list);
} else if (capture_opts->capture_child) {
/* In Wireshark capture child mode, thus proper device name is supplied. */
/* No need for trying to match it for friendly names. */
interface_opts.name = g_strdup(optarg_str_p);
interface_opts.console_display_name = g_strdup(optarg_str_p);
} else {
/*
* Retrieve the interface list so that we can search for the

View File

@ -202,6 +202,7 @@ typedef struct capture_options_tag {
/* internally used (don't touch from outside) */
gboolean output_to_pipe; /**< save_file is a pipe (named or stdout) */
gboolean capture_child; /**< hidden option: Wireshark child mode */
} capture_options;
/* initialize the capture_options with some reasonable values */

View File

@ -956,7 +956,7 @@ sync_pipe_close_command(int *data_read_fd, int *message_read_fd,
/* XXX - assumes PIPE_BUF_SIZE > SP_MAX_MSG_LEN */
#define PIPE_BUF_SIZE 5120
static int
sync_pipe_run_command(char** argv, gchar **data, gchar **primary_msg,
sync_pipe_run_command_actual(char** argv, gchar **data, gchar **primary_msg,
gchar **secondary_msg)
{
gchar *msg;
@ -1128,6 +1128,43 @@ sync_pipe_run_command(char** argv, gchar **data, gchar **primary_msg,
return ret;
}
/* centralised logging and timing for sync_pipe_run_command_actual(),
* redirects to sync_pipe_run_command_actual()
*/
static int
sync_pipe_run_command(char** argv, gchar **data, gchar **primary_msg,
gchar **secondary_msg)
{
int ret, i;
GTimeVal start_time;
GTimeVal end_time;
float elapsed;
int logging_enabled;
/* check if logging is actually enabled, otherwise don't expend the CPU generating logging */
logging_enabled=( (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO) & G_LOG_LEVEL_MASK & prefs.console_log_level);
if(logging_enabled){
g_get_current_time(&start_time);
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "sync_pipe_run_command() starts");
for(i=0; argv[i] != 0; i++) {
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, " argv[%d]: %s", i, argv[i]);
}
}
/* do the actual sync pipe run command */
ret=sync_pipe_run_command_actual(argv, data, primary_msg, secondary_msg);
if(logging_enabled){
g_get_current_time(&end_time);
elapsed = (float) ((end_time.tv_sec - start_time.tv_sec) +
((end_time.tv_usec - start_time.tv_usec) / 1e6));
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "sync_pipe_run_command() ends, taking %.3fs, result=%d", elapsed, ret);
}
return ret;
}
int
sync_interface_set_80211_chan(const gchar *iface, const char *freq, const gchar *type,
gchar **data, gchar **primary_msg,
@ -1236,7 +1273,7 @@ sync_if_capabilities_open(const gchar *ifname, gboolean monitor_mode,
int argc;
char **argv;
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_linktype_list_open");
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_if_capabilities_open");
argv = init_pipe_args(&argc);

View File

@ -4459,6 +4459,9 @@ main(int argc, char *argv[])
global_capture_opts.saving_to_file = TRUE;
global_capture_opts.has_ring_num_files = TRUE;
/* Pass on capture_child mode for capture_opts */
global_capture_opts.capture_child = capture_child;
/* Now get our args */
while ((opt = getopt(argc, argv, OPTSTRING)) != -1) {
switch (opt) {

View File

@ -38,6 +38,7 @@
#include "ui/capture_globals.h"
#include "ui/iface_lists.h"
#include "../log.h"
/*
* Used when sorting an interface list into alphabetical order by
@ -341,18 +342,33 @@ scan_local_interfaces(void)
}
/*
* Get the global interface list. Generate it if we haven't
* done so already.
* Get the global interface list. Generate it if we haven't done so
* already. This can be quite time consuming the first time, so
* record how long it takes in the info log.
*/
void
fill_in_local_interfaces(void)
{
static gboolean initialized = FALSE;
GTimeVal start_time;
GTimeVal end_time;
float elapsed;
static gboolean initialized = FALSE;
/* record the time we started, so we can log total time later */
g_get_current_time(&start_time);
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "fill_in_local_interfaces() starts");
if (!initialized) {
/* do the actual work */
scan_local_interfaces();
initialized = TRUE;
}
/* log how long it took */
g_get_current_time(&end_time);
elapsed = (float) ((end_time.tv_sec - start_time.tv_sec) +
((end_time.tv_usec - start_time.tv_usec) / 1e6));
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "fill_in_local_interfaces() ends, taking %.3fs", elapsed);
}
void