aboutsummaryrefslogtreecommitdiffstats
path: root/mmdbresolve.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2018-05-22 15:54:55 -0700
committerAnders Broman <a.broman58@gmail.com>2018-05-24 04:07:44 +0000
commitc159d48420e184f068ed6cea1715ab697fda4f7d (patch)
tree5cc51340ed188eee09062e1bb5879de2a912662d /mmdbresolve.c
parentdcececa79fdb00348cc1d93f53af41b5a639946a (diff)
maxmind: Move request processing to a thread.
It's possible to block while we're writing to our mmdbresolve pipe, particularly on Windows. Move the write to a separate thread. Add an #ifdef to mmdbresolve.c which helps test blocking. Bug: 14701 Change-Id: I6cb8a46a190a268da64f1e6f54d1052d03743c95 Reviewed-on: https://code.wireshark.org/review/27750 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'mmdbresolve.c')
-rw-r--r--mmdbresolve.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/mmdbresolve.c b/mmdbresolve.c
index 5f6edafd9b..3b0018976c 100644
--- a/mmdbresolve.c
+++ b/mmdbresolve.c
@@ -23,6 +23,15 @@
#define MMDBR_STRINGIFY_S(s) #s
#define OUT_BUF_SIZE 65536
+// Uncomment to enable slow lookups. Only useful on Windows for now.
+// #define MMDB_DEBUG_SLOW 1
+
+#ifdef MMDB_DEBUG_SLOW
+#ifdef _WIN32
+#include <Windows.h>
+#endif
+#endif
+
static const char *co_iso_key[] = {"country", "iso_code", NULL};
static const char *co_name_key[] = {"country", "names", "en", NULL};
static const char *ci_name_key[] = {"city", "names", "en", NULL};
@@ -107,6 +116,12 @@ main(int argc, char *argv[])
}
fprintf(stdout, "[%s]\n", addr_str);
+#ifdef MMDB_DEBUG_SLOW
+#ifdef _WIN32
+ Sleep(1000);
+#endif
+#endif
+
for (size_t mmdb_idx = 0; mmdb_idx < mmdb_count; mmdb_idx++) {
fprintf(stdout, "# %s\n", mmdbs[mmdb_idx].metadata.database_type);
MMDB_lookup_result_s result = MMDB_lookup_string(&mmdbs[mmdb_idx], addr_str, &gai_err, &mmdb_err);