summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-10-23 12:20:58 -0400
committerNick Mathewson <nickm@torproject.org>2017-10-23 12:22:26 -0400
commit48ee85e0c6c83c31693bc58ca4e8e91c8031421d (patch)
tree065423caedd52fc6ca61b572399ecb7782dcb4bf /src/or
parent8b8d501040946bb2280a9640f91a55b7f17b03e3 (diff)
downloadtor-48ee85e0c6c83c31693bc58ca4e8e91c8031421d.tar.gz
tor-48ee85e0c6c83c31693bc58ca4e8e91c8031421d.zip
Have LOG_PROTOCOL_WARN call its own function
Also, make the function that implements LOG_PROTOCOL_WARN use a cached value of the desired loglevel, rather than calling get_options().
Diffstat (limited to 'src/or')
-rw-r--r--src/or/config.c22
-rw-r--r--src/or/config.h1
-rw-r--r--src/or/or.h4
3 files changed, 25 insertions, 2 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 94c4d790ac..a2353b94db 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1030,6 +1030,23 @@ escaped_safe_str(const char *address)
return escaped(address);
}
+/**
+ * The severity level that should be used for warnings of severity
+ * LOG_PROTOCOL_WARN.
+ *
+ * We keep this outside the options, in case somebody needs to use
+ * LOG_PROTOCOL_WARN while an option transition is happening.
+ */
+static int protocol_warning_severity_level = LOG_WARN;
+
+/** Return the severity level that should be used for warnings of severity
+ * LOG_PROTOCOL_WARN. */
+int
+get_protocol_warning_severity_level(void)
+{
+ return protocol_warning_severity_level;
+}
+
/** List of default directory authorities */
static const char *default_authorities[] = {
@@ -1667,6 +1684,11 @@ options_act(const or_options_t *old_options)
return -1;
}
+ if (options->ProtocolWarnings)
+ protocol_warning_severity_level = LOG_WARN;
+ else
+ protocol_warning_severity_level = LOG_INFO;
+
if (consider_adding_dir_servers(options, old_options) < 0)
return -1;
diff --git a/src/or/config.h b/src/or/config.h
index f69a3c483f..af945f16be 100644
--- a/src/or/config.h
+++ b/src/or/config.h
@@ -31,6 +31,7 @@ const char *safe_str_client(const char *address);
const char *safe_str(const char *address);
const char *escaped_safe_str_client(const char *address);
const char *escaped_safe_str(const char *address);
+int get_protocol_warning_severity_level(void);
const char *get_version(void);
const char *get_short_version(void);
setopt_err_t options_trial_assign(config_line_t *list, unsigned flags,
diff --git a/src/or/or.h b/src/or/or.h
index 5bd07ba6a3..8c1ef478ed 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -4079,8 +4079,6 @@ typedef struct {
int Sandbox; /**< Boolean: should sandboxing be enabled? */
int SafeSocks; /**< Boolean: should we outright refuse application
* connections that use socks4 or socks5-with-local-dns? */
-#define LOG_PROTOCOL_WARN (get_options()->ProtocolWarnings ? \
- LOG_WARN : LOG_INFO)
int ProtocolWarnings; /**< Boolean: when other parties screw up the Tor
* protocol, is it a warn or an info in our logs? */
int TestSocks; /**< Boolean: when we get a socks connection, do we loudly
@@ -4627,6 +4625,8 @@ typedef struct {
smartlist_t *SchedulerTypes_;
} or_options_t;
+#define LOG_PROTOCOL_WARN (get_protocol_warning_severity_level())
+
/** Persistent state for an onion router, as saved to disk. */
typedef struct {
uint32_t magic_;