]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
asn_{open,close}: Always initialize ipinfo hash table
authormeingtsla <meingtsla@users.noreply.github.com>
Sun, 30 Oct 2016 04:16:04 +0000 (21:16 -0700)
committermeingtsla <meingtsla@users.noreply.github.com>
Sun, 30 Oct 2016 04:16:04 +0000 (21:16 -0700)
Currently the only pathway to asn_open() is through display_open(), so hcreate() for ipinfo was only happening if -y or -z was specified at startup.

The ability to toggle ipinfo display in interactive mode was introduced in commit d4bb85a80ee3eb76d803e3cd04de2ccdf0379415; however, no pathway to asn_open on a toggle event was provided.  This means ipinfo results were not being stored, resulting in repeated ipinfo DNS queries being made for the same IP addresses.

To fix this, always set up the hash table if there is a possibility of toggling ipinfo display.

asn.c

diff --git a/asn.c b/asn.c
index bbf418041c0e6bfdd4992874b00d3b4c622b5641..c39a78e237176e316fe206aae5662489920f5de2 100644 (file)
--- a/asn.c
+++ b/asn.c
@@ -278,15 +278,13 @@ extern int is_printii(struct mtr_ctl *ctl) {
 }
 
 extern void asn_open(struct mtr_ctl *ctl) {
-    if (ctl->ipinfo_no >= 0) {
-        DEB_syslog(LOG_INFO, "hcreate(%d)", IIHASH_HI);
-        if (!(iihash = hcreate(IIHASH_HI)))
-            error(0, errno, "ipinfo hash");
-    }
+    DEB_syslog(LOG_INFO, "hcreate(%d)", IIHASH_HI);
+    if (!(iihash = hcreate(IIHASH_HI)))
+        error(0, errno, "ipinfo hash");
 }
 
 extern void asn_close(struct mtr_ctl *ctl) {
-    if ((ctl->ipinfo_no >= 0) && iihash) {
+    if (iihash) {
         DEB_syslog(LOG_INFO, "hdestroy()");
         hdestroy();
         iihash = 0;