diff options
author | sahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7> | 2002-09-05 06:46:38 +0000 |
---|---|---|
committer | sahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7> | 2002-09-05 06:46:38 +0000 |
commit | 1bfc30f6e5f7e843b8f61a0e7b0847f84eed7c75 (patch) | |
tree | b2e86de21e4f1573b293b3030213bb1994641316 /gtk2 | |
parent | d377cf814885c3f49b1fbd63e0f47aac65ce3248 (diff) |
Added a mutex to protect a critical region in Gtk2 where the list can be
modified while the draw thread is walking it.
Changed the cmdline switch to -z so the same one can be used both for
ethereal and tethereal.
Updated man pages to reflect the RPCSTAT feature.
(Try this with Tools/Statistics/ONC-RPC/RTT and load a capture containing
onc-rpc. )
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@6189 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk2')
-rw-r--r-- | gtk2/gtk2-rpcstat.c | 24 | ||||
-rw-r--r-- | gtk2/main.c | 30 |
2 files changed, 49 insertions, 5 deletions
diff --git a/gtk2/gtk2-rpcstat.c b/gtk2/gtk2-rpcstat.c index 2b1484ee34..f87d372a06 100644 --- a/gtk2/gtk2-rpcstat.c +++ b/gtk2/gtk2-rpcstat.c @@ -1,7 +1,7 @@ /* gtk2-rpcstat.c * rpcstat 2002 Ronnie Sahlberg * - * $Id: gtk2-rpcstat.c,v 1.1 2002/09/04 22:18:12 sahlberg Exp $ + * $Id: gtk2-rpcstat.c,v 1.2 2002/09/05 06:46:38 sahlberg Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -46,6 +46,7 @@ #include "tap-rpcstat.h" #include "packet-rpc.h" +extern GStaticMutex update_thread_mutex; /* used to keep track of statistics for a specific procedure */ typedef struct _rpc_procedure_t { @@ -254,20 +255,29 @@ rpcstat_find_vers(gpointer *key, gpointer *value _U_, gpointer *user_data _U_) return NULL; } +/* since the gtk2 implementation of tap is multithreaded we must protect + * remove_tap_listener() from modifying the list while draw_tap_listener() + * is running. the other protected block is in main.c + * + * there should not be any other critical regions in gtk2 + */ static void win_destroy_cb(GtkWindow *win _U_, gpointer data) { rpcstat_t *rs=(rpcstat_t *)data; + g_static_mutex_lock(&update_thread_mutex); remove_tap_listener(rs); + g_static_mutex_unlock(&update_thread_mutex); + g_free(rs->procedures); g_free(rs); } /* When called, this function will create a new instance of gtk2-rpcstat. */ -static void -rpcstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_) +void +gtk2_rpcstat_init(guint32 program, guint32 version) { rpcstat_t *rs; guint32 i; @@ -276,6 +286,8 @@ rpcstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_) GtkWidget *stat_label; GtkWidget *tmp; + rpc_program=program; + rpc_version=version; rs=g_malloc(sizeof(rpcstat_t)); rs->prog=rpc_prog_name(rpc_program); rs->program=rpc_program; @@ -381,6 +393,12 @@ rpcstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_) gtk_widget_show_all(rs->win); } +static void +rpcstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_) +{ + gtk2_rpcstat_init(rpc_program, rpc_version); +} + diff --git a/gtk2/main.c b/gtk2/main.c index 2757484101..1dcd6bede5 100644 --- a/gtk2/main.c +++ b/gtk2/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.2 2002/09/04 22:19:42 sahlberg Exp $ + * $Id: main.c,v 1.3 2002/09/05 06:46:38 sahlberg Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -135,6 +135,7 @@ #include "image/clist_ascend.xpm" #include "image/clist_descend.xpm" #include "../tap.h" +#include "gtk2-rpcstat.h" #ifdef WIN32 #include "capture-wpcap.h" @@ -1211,13 +1212,18 @@ set_autostop_criterion(const char *autostoparg) } #endif + +GStaticMutex update_thread_mutex = G_STATIC_MUTEX_INIT; + gpointer update_thread(gpointer data _U_) { while(1){ struct timeval tv1, tv2; gettimeofday(&tv1, NULL); + g_static_mutex_lock(&update_thread_mutex); draw_tap_listeners(FALSE); + g_static_mutex_unlock(&update_thread_mutex); do{ g_thread_yield(); gettimeofday(&tv2, NULL); @@ -1272,7 +1278,7 @@ main(int argc, char *argv[]) gboolean prefs_write_needed = FALSE; -#define OPTSTRING_INIT "a:b:B:c:f:hi:klm:nN:o:pP:Qr:R:Ss:t:T:w:v" +#define OPTSTRING_INIT "a:b:B:c:f:hi:klm:nN:o:pP:Qr:R:Ss:t:T:w:vz:" #ifdef HAVE_LIBPCAP #ifdef WIN32 @@ -1708,6 +1714,26 @@ main(int argc, char *argv[]) break; #endif + case 'z': + if(!strncmp(optarg,"rpc,",4)){ + if(!strncmp(optarg,"rpc,rtt,",8)){ + int rpcprogram, rpcversion; + if(sscanf(optarg,"rpc,rtt,%d,%d",&rpcprogram,&rpcversion)==2){ + gtk2_rpcstat_init(rpcprogram,rpcversion); + } else { + fprintf(stderr, "ethereal: invalid \"-z rpc,rtt,<program>,<version>\" argument\n"); + exit(1); + } + } else { + fprintf(stderr, "ethereal: invalid -z argument. Argument must be \"-z rpc,rtt,...\"\n"); + exit(1); + } + } else { + fprintf(stderr, "ethereal: invalid -z argument. Argument must be \"-z rpc,...\"\n"); + exit(1); + } + break; + #ifdef _WIN32 #ifdef HAVE_LIBPCAP /* Hidden option supporting Sync mode */ |