aboutsummaryrefslogtreecommitdiffstats
path: root/epan/epan.c
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2019-09-04 13:51:29 +0200
committerAnders Broman <a.broman58@gmail.com>2019-09-04 12:31:53 +0000
commit98cda1bf46fb262dbfd1865cf131a23504a41cec (patch)
tree9dba36fdaf4f3c885760ace24c2e76c7b00e70d6 /epan/epan.c
parentf2162a1005328a4921367cc52b767f7629944330 (diff)
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>
Diffstat (limited to 'epan/epan.c')
-rw-r--r--epan/epan.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/epan/epan.c b/epan/epan.c
index cc4327d270..f06d4c0ea6 100644
--- a/epan/epan.c
+++ b/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