Load environment vars to globals for efficency.
These environment variables are read very frequently, read them once to globals for performance improvment. Change-Id: I4f05a5edca85b370674cc5f85fce40bd1af695cb Reviewed-on: https://code.wireshark.org/review/34449 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
f2162a1005
commit
98cda1bf46
|
@ -122,7 +122,7 @@ void capture_dissector_add_uint(const char *name, const guint32 pattern, capture
|
|||
sub_dissectors = (struct capture_dissector_table*)g_hash_table_lookup( capture_dissector_tables, name );
|
||||
if (sub_dissectors == NULL) {
|
||||
fprintf(stderr, "OOPS: Subdissector \"%s\" not found in capture_dissector_tables\n", name);
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -557,7 +557,7 @@ rpc_init_prog(int proto, guint32 prog, int ett, size_t nvers,
|
|||
proc->strptr);
|
||||
|
||||
/* Abort out if desired - but don't throw an exception here! */
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
REPORT_DISSECTOR_BUG("RPC: No call handler!");
|
||||
|
||||
continue;
|
||||
|
@ -572,7 +572,7 @@ rpc_init_prog(int proto, guint32 prog, int ett, size_t nvers,
|
|||
proc->strptr);
|
||||
|
||||
/* Abort out if desired - but don't throw an exception here! */
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
REPORT_DISSECTOR_BUG("RPC: No reply handler!");
|
||||
|
||||
continue;
|
||||
|
|
22
epan/epan.c
22
epan/epan.c
|
@ -98,6 +98,12 @@ static GSList *epan_plugin_register_all_handoffs = NULL;
|
|||
|
||||
static wmem_allocator_t *pinfo_pool_cache = NULL;
|
||||
|
||||
/* Global variables holding the content of the corresponding environment variable
|
||||
* to save fetching it repeatedly.
|
||||
*/
|
||||
gboolean wireshark_abort_on_dissector_bug = FALSE;
|
||||
gboolean wireshark_abort_on_too_many_items = FALSE;
|
||||
|
||||
#ifdef HAVE_PLUGINS
|
||||
plugins_t *libwireshark_plugins = NULL;
|
||||
static GSList *epan_plugins = NULL;
|
||||
|
@ -192,6 +198,22 @@ epan_init(register_cb cb, gpointer client_data, gboolean load_plugins)
|
|||
{
|
||||
volatile gboolean status = TRUE;
|
||||
|
||||
/* Get the value of some environment variables and set corresponding globals for performance reasons*/
|
||||
/* If the WIRESHARK_ABORT_ON_DISSECTOR_BUG environment variable is set,
|
||||
* it will call abort(), instead, to make it easier to get a stack trace.
|
||||
*/
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL) {
|
||||
wireshark_abort_on_dissector_bug = TRUE;
|
||||
} else {
|
||||
wireshark_abort_on_dissector_bug = FALSE;
|
||||
}
|
||||
|
||||
if (getenv("WIRESHARK_ABORT_ON_TOO_MANY_ITEMS") != NULL) {
|
||||
wireshark_abort_on_too_many_items = TRUE;
|
||||
} else {
|
||||
wireshark_abort_on_too_many_items = FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* proto_init -> register_all_protocols -> g_async_queue_new which
|
||||
* requires threads to be initialized. This happens automatically with
|
||||
|
|
10
epan/epan.h
10
epan/epan.h
|
@ -22,12 +22,18 @@ extern "C" {
|
|||
#include <epan/register.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
|
||||
/** Global variable holding the content of the corresponding environment variable
|
||||
* to save fetching it repeatedly.
|
||||
*/
|
||||
extern gboolean wireshark_abort_on_dissector_bug;
|
||||
|
||||
typedef struct epan_dissect epan_dissect_t;
|
||||
|
||||
struct epan_dfilter;
|
||||
struct epan_column_info;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Opaque structure provided when an epan_t is created; it contains
|
||||
* information needed to allow the user of libwireshark to provide
|
||||
* time stamps, comments, and other information outside the packet
|
||||
|
@ -35,7 +41,7 @@ struct epan_column_info;
|
|||
*/
|
||||
struct packet_provider_data;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Structure containing pointers to functions supplied by the user
|
||||
* of libwireshark.
|
||||
*/
|
||||
|
|
|
@ -174,7 +174,7 @@ static void uat_expert_post_update_cb(void)
|
|||
}
|
||||
|
||||
#define EXPERT_REGISTRAR_GET_NTH(eiindex, expinfo) \
|
||||
if((guint)eiindex >= gpa_expertinfo.len && getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG")) \
|
||||
if((guint)eiindex >= gpa_expertinfo.len && wireshark_abort_on_dissector_bug) \
|
||||
g_error("Unregistered expert info! index=%d", eiindex); \
|
||||
DISSECTOR_ASSERT_HINT((guint)eiindex < gpa_expertinfo.len, "Unregistered expert info!"); \
|
||||
DISSECTOR_ASSERT_HINT(gpa_expertinfo.ei[eiindex] != NULL, "Unregistered expert info!"); \
|
||||
|
|
|
@ -1023,7 +1023,7 @@ dissector_add_uint(const char *name, const guint32 pattern, dissector_handle_t h
|
|||
if (handle == NULL) {
|
||||
fprintf(stderr, "OOPS: handle to register \"%s\" to doesn't exist\n",
|
||||
name);
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
@ -1032,7 +1032,7 @@ dissector_add_uint(const char *name, const guint32 pattern, dissector_handle_t h
|
|||
name);
|
||||
fprintf(stderr, "Protocol being registered is \"%s\"\n",
|
||||
proto_get_protocol_long_name(handle->protocol));
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
@ -1506,7 +1506,7 @@ dissector_add_string(const char *name, const gchar *pattern,
|
|||
if (handle == NULL) {
|
||||
fprintf(stderr, "OOPS: handle to register \"%s\" to doesn't exist\n",
|
||||
name);
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
@ -1515,7 +1515,7 @@ dissector_add_string(const char *name, const gchar *pattern,
|
|||
name);
|
||||
fprintf(stderr, "Protocol being registered is \"%s\"\n",
|
||||
proto_get_protocol_long_name(handle->protocol));
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
@ -1768,7 +1768,7 @@ void dissector_add_custom_table_handle(const char *name, void *pattern, dissecto
|
|||
if (handle == NULL) {
|
||||
fprintf(stderr, "OOPS: handle to register \"%s\" to doesn't exist\n",
|
||||
name);
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
@ -1777,7 +1777,7 @@ void dissector_add_custom_table_handle(const char *name, void *pattern, dissecto
|
|||
name);
|
||||
fprintf(stderr, "Protocol being registered is \"%s\"\n",
|
||||
proto_get_protocol_long_name(handle->protocol));
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
@ -1824,7 +1824,7 @@ void dissector_add_guid(const char *name, guid_key* guid_val, dissector_handle_t
|
|||
if (handle == NULL) {
|
||||
fprintf(stderr, "OOPS: handle to register \"%s\" to doesn't exist\n",
|
||||
name);
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
@ -1833,7 +1833,7 @@ void dissector_add_guid(const char *name, guid_key* guid_val, dissector_handle_t
|
|||
name);
|
||||
fprintf(stderr, "Protocol being registered is \"%s\"\n",
|
||||
proto_get_protocol_long_name(handle->protocol));
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
@ -2019,7 +2019,7 @@ dissector_add_for_decode_as(const char *name, dissector_handle_t handle)
|
|||
name);
|
||||
fprintf(stderr, "Protocol being registered is \"%s\"\n",
|
||||
proto_get_protocol_long_name(handle->protocol));
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
@ -2037,7 +2037,7 @@ dissector_add_for_decode_as(const char *name, dissector_handle_t handle)
|
|||
dissector_name,
|
||||
proto_get_protocol_short_name(handle->protocol),
|
||||
name);
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
@ -2081,7 +2081,7 @@ dissector_add_for_decode_as(const char *name, dissector_handle_t handle)
|
|||
dissector_name, dup_dissector_name,
|
||||
proto_get_protocol_short_name(handle->protocol),
|
||||
name);
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
@ -2621,7 +2621,7 @@ heur_dissector_add(const char *name, heur_dissector_t dissector, const char *dis
|
|||
fprintf(stderr, "Protocol being registered is \"%s\"\n",
|
||||
proto_name);
|
||||
}
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
@ -2640,7 +2640,7 @@ heur_dissector_add(const char *name, heur_dissector_t dissector, const char *dis
|
|||
fprintf(stderr, "Protocol %s is already registered in \"%s\" table\n",
|
||||
proto_name, name);
|
||||
}
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
|
||||
if (wireshark_abort_on_dissector_bug)
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -363,7 +363,7 @@ static GHashTable* prefixes = NULL;
|
|||
wmem_free(pool, il);
|
||||
|
||||
#define PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo) \
|
||||
if((guint)hfindex >= gpa_hfinfo.len && getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG")) \
|
||||
if((guint)hfindex >= gpa_hfinfo.len && wireshark_abort_on_dissector_bug) \
|
||||
g_error("Unregistered hf! index=%d", hfindex); \
|
||||
DISSECTOR_ASSERT_HINT((guint)hfindex < gpa_hfinfo.len, "Unregistered hf!"); \
|
||||
DISSECTOR_ASSERT_HINT(gpa_hfinfo.hfi[hfindex] != NULL, "Unregistered hf!"); \
|
||||
|
@ -1454,7 +1454,7 @@ void proto_report_dissector_bug(const char *format, ...)
|
|||
{
|
||||
va_list args;
|
||||
|
||||
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL) {
|
||||
if (wireshark_abort_on_dissector_bug) {
|
||||
/*
|
||||
* Try to have the error message show up in the crash
|
||||
* information.
|
||||
|
|
Loading…
Reference in New Issue