浏览代码

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().
Nick Mathewson 7 年之前
父节点
当前提交
48ee85e0c6
共有 4 个文件被更改,包括 29 次插入2 次删除
  1. 4 0
      changes/bug23952
  2. 22 0
      src/or/config.c
  3. 1 0
      src/or/config.h
  4. 2 2
      src/or/or.h

+ 4 - 0
changes/bug23952

@@ -0,0 +1,4 @@
+  o Minor bugfixes (relay):
+    - Avoid a BUG warning when receiving a dubious CREATE cell while
+      an option transition is in progress. Fixes bug 23952; bugfix on
+      0.3.2.1-alpha.

+ 22 - 0
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;
 

+ 1 - 0
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,

+ 2 - 2
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_;