diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-02-18 12:32:00 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-02-18 12:46:10 -0500 |
commit | c43a2452921ac86e65eb70797c8a82b82c2b4076 (patch) | |
tree | cef341f060c37e4b6d586aa0f91720e18c9a3cdf /src/feature/relay/dns.h | |
parent | 1f06f494c8ce45946e565237a8a52785a8ece447 (diff) | |
download | tor-c43a2452921ac86e65eb70797c8a82b82c2b4076.tar.gz tor-c43a2452921ac86e65eb70797c8a82b82c2b4076.zip |
Disable dns.c when relay mode is disabled.
This saves about 1% for me on a binary compiled without relay mode.
Closes ticket 33366.
Diffstat (limited to 'src/feature/relay/dns.h')
-rw-r--r-- | src/feature/relay/dns.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/feature/relay/dns.h b/src/feature/relay/dns.h index a2275c724a..4e5766af0c 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" |