aboutsummaryrefslogtreecommitdiffstats
path: root/epan/addr_resolv.c
diff options
context:
space:
mode:
authorEvan Huus <eapache@gmail.com>2014-06-30 19:46:58 -0400
committerAnders Broman <a.broman58@gmail.com>2014-07-01 04:21:14 +0000
commita452d16f2c27fc44a41f14d05acca8e94b1c71d8 (patch)
tree085907efa4a91520b08443bebeead97f201f3764 /epan/addr_resolv.c
parent659d0efc928e102d8ca0390a374cddcbad7d8797 (diff)
Optimize epan_new/init_dissection
As Anders correctly pointed out in I7d8f84b2e, constantly resetting state will turn init_dissection into a bit of a hot path. Especially as we will already bear the overhead of switching files, we don't want to fall any further behind than we have to. This change includes three unrelated optimizations that reduce the cost of init_dissection by about 40% as measured by callgrind: - only initialize ares/ADNS if that preference is enabled (this of course only applies if you specify -n to tshark or otherwise disable the preference) - use memcpy instead of a loop in sigcomp UDVM init - use memcpy instead of a loop in bootp dissector The only remaining obvious hot spot in this path is reassembly_table_init since it is called by so many dissectors. Suggestions (perhaps to get rid of the GPtrArray) welcome. Oh, and one other change to use g_strerror instead of strerror as insisted upon by the API pre-commit hook. Change-Id: I18a74f2b64b25498116079bd4e7fc2b335c7703a Reviewed-on: https://code.wireshark.org/review/2738 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/addr_resolv.c')
-rw-r--r--epan/addr_resolv.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index 595b50fe80..fbfc7295de 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -2393,7 +2393,7 @@ host_name_lookup_process(void) {
nfds = ares_fds(ghba_chan, &rfds, &wfds);
if (nfds > 0) {
if (select(nfds, &rfds, &wfds, NULL, &tv) == -1) { /* call to select() failed */
- fprintf(stderr, "Warning: call to select() failed, error is %s\n", strerror(errno));
+ fprintf(stderr, "Warning: call to select() failed, error is %s\n", g_strerror(errno));
return nro;
}
ares_process(ghba_chan, &rfds, &wfds);
@@ -2688,15 +2688,17 @@ host_name_lookup_init(void)
}
g_free(hostspath);
#ifdef HAVE_C_ARES
+ if (gbl_resolv_flags.concurrent_dns) {
#ifdef CARES_HAVE_ARES_LIBRARY_INIT
- if (ares_library_init(ARES_LIB_INIT_ALL) == ARES_SUCCESS) {
+ if (ares_library_init(ARES_LIB_INIT_ALL) == ARES_SUCCESS) {
#endif
- if (ares_init(&ghba_chan) == ARES_SUCCESS && ares_init(&ghbn_chan) == ARES_SUCCESS) {
- async_dns_initialized = TRUE;
- }
+ if (ares_init(&ghba_chan) == ARES_SUCCESS && ares_init(&ghbn_chan) == ARES_SUCCESS) {
+ async_dns_initialized = TRUE;
+ }
#ifdef CARES_HAVE_ARES_LIBRARY_INIT
- }
+ }
#endif
+ }
#else
#ifdef HAVE_GNU_ADNS
/*
@@ -2732,21 +2734,23 @@ host_name_lookup_init(void)
}
#endif /* _WIN32 */
- /* XXX - Any flags we should be using? */
- /* XXX - We could provide config settings for DNS servers, and
- pass them to ADNS with adns_init_strcfg */
- if (adns_init(&ads, adns_if_none, 0 /*0=>stderr*/) != 0) {
- /*
- * XXX - should we report the error? I'm assuming that some crashes
- * reported on a Windows machine with TCP/IP not configured are due
- * to "adns_init()" failing (due to the lack of TCP/IP) and leaving
- * ADNS in a state where it crashes due to that. We'll still try
- * doing name resolution anyway.
- */
- return;
+ if (gbl_resolv_flags.concurrent_dns) {
+ /* XXX - Any flags we should be using? */
+ /* XXX - We could provide config settings for DNS servers, and
+ pass them to ADNS with adns_init_strcfg */
+ if (adns_init(&ads, adns_if_none, 0 /*0=>stderr*/) != 0) {
+ /*
+ * XXX - should we report the error? I'm assuming that some crashes
+ * reported on a Windows machine with TCP/IP not configured are due
+ * to "adns_init()" failing (due to the lack of TCP/IP) and leaving
+ * ADNS in a state where it crashes due to that. We'll still try
+ * doing name resolution anyway.
+ */
+ return;
+ }
+ async_dns_initialized = TRUE;
+ async_dns_in_flight = 0;
}
- async_dns_initialized = TRUE;
- async_dns_in_flight = 0;
#endif /* HAVE_GNU_ADNS */
#endif /* HAVE_C_ARES */
@@ -3221,7 +3225,7 @@ get_host_ipaddr(const char *host, guint32 *addrp)
if (nfds > 0) {
tvp = ares_timeout(ghbn_chan, &tv, &tv);
if (select(nfds, &rfds, &wfds, NULL, tvp) == -1) { /* call to select() failed */
- fprintf(stderr, "Warning: call to select() failed, error is %s\n", strerror(errno));
+ fprintf(stderr, "Warning: call to select() failed, error is %s\n", g_strerror(errno));
return FALSE;
}
ares_process(ghbn_chan, &rfds, &wfds);
@@ -3308,7 +3312,7 @@ get_host_ipaddr6(const char *host, struct e_in6_addr *addrp)
if (nfds > 0) {
tvp = ares_timeout(ghbn_chan, &tv, &tv);
if (select(nfds, &rfds, &wfds, NULL, tvp) == -1) { /* call to select() failed */
- fprintf(stderr, "Warning: call to select() failed, error is %s\n", strerror(errno));
+ fprintf(stderr, "Warning: call to select() failed, error is %s\n", g_strerror(errno));
return FALSE;
}
ares_process(ghbn_chan, &rfds, &wfds);