[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Disable dns.c when relay mode is disabled.



commit c43a2452921ac86e65eb70797c8a82b82c2b4076
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Feb 18 12:32:00 2020 -0500

    Disable dns.c when relay mode is disabled.
    
    This saves about 1% for me on a binary compiled without relay mode.
    
    Closes ticket 33366.
---
 changes/ticket33366          |  3 +++
 src/feature/relay/dns.h      | 39 +++++++++++++++++++++++++++++++++++++++
 src/feature/relay/include.am |  2 +-
 3 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/changes/ticket33366 b/changes/ticket33366
new file mode 100644
index 000000000..1310c493c
--- /dev/null
+++ b/changes/ticket33366
@@ -0,0 +1,3 @@
+  o Minor features (compilation size):
+    - Most Server-side DNS code is now disabled when building without
+      support for relay mode. Closes ticket 33366.
diff --git a/src/feature/relay/dns.h b/src/feature/relay/dns.h
index a2275c724..4e5766af0 100644
--- a/src/feature/relay/dns.h
+++ b/src/feature/relay/dns.h
@@ -12,6 +12,8 @@
 #ifndef TOR_DNS_H
 #define TOR_DNS_H
 
+#ifdef HAVE_MODULE_RELAY
+
 int dns_init(void);
 int has_dns_init_failed(void);
 void dns_free_all(void);
@@ -29,6 +31,43 @@ size_t dns_cache_total_allocation(void);
 void dump_dns_mem_usage(int severity);
 size_t dns_cache_handle_oom(time_t now, size_t min_remove_bytes);
 
+#else /* !defined(HAVE_MODULE_RELAY) */
+
+#define dns_init() (0)
+#define dns_seems_to_be_broken() (0)
+#define has_dns_init_failed() (0)
+#define dns_cache_total_allocation() (0)
+
+#define dns_reset_correctness_checks() STMT_NIL
+
+#define assert_connection_edge_not_dns_pending(conn) \
+  ((void)(conn))
+#define dump_dns_mem_usage(severity)\
+  ((void)(severity))
+#define dns_cache_handle_oom(now, bytes) \
+  ((void)(now), (void)(bytes), 0)
+
+#define connection_dns_remove(conn) \
+  STMT_BEGIN                        \
+  (void)(conn);                     \
+  tor_assert_nonfatal_unreached();  \
+  STMT_END
+
+static inline int
+dns_reset(void)
+{
+  return 0;
+}
+static inline int
+dns_resolve(edge_connection_t *exitconn)
+{
+  (void)exitconn;
+  tor_assert_nonfatal_unreached();
+  return -1;
+}
+
+#endif /* defined(HAVE_MODULE_RELAY) */
+
 #ifdef DNS_PRIVATE
 #include "feature/relay/dns_structs.h"
 
diff --git a/src/feature/relay/include.am b/src/feature/relay/include.am
index a4c025ae1..ad81e60d7 100644
--- a/src/feature/relay/include.am
+++ b/src/feature/relay/include.am
@@ -1,7 +1,6 @@
 
 # Legacy shared relay code: migrate to the relay module over time
 LIBTOR_APP_A_SOURCES += 			\
-	src/feature/relay/dns.c			\
 	src/feature/relay/ext_orport.c		\
 	src/feature/relay/onion_queue.c		\
 	src/feature/relay/router.c		\
@@ -12,6 +11,7 @@ LIBTOR_APP_A_SOURCES += 			\
 
 # ADD_C_FILE: INSERT SOURCES HERE.
 MODULE_RELAY_SOURCES = 						\
+	src/feature/relay/dns.c					\
 	src/feature/relay/routermode.c				\
 	src/feature/relay/relay_config.c			\
 	src/feature/relay/relay_periodic.c			\



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits