Преглед изворни кода

r18872@catbus: nickm | 2008-03-16 23:56:48 -0400
Only dump all guard node status to the log when the guard node status actually changes. Downgrade the 4 most common remaining INFO log messages to DEBUG.


svn:r14069

Nick Mathewson пре 17 година
родитељ
комит
e6b617bf05
4 измењених фајлова са 25 додато и 16 уклоњено
  1. 3 0
      ChangeLog
  2. 18 12
      src/or/circuitbuild.c
  3. 2 2
      src/or/connection.c
  4. 2 2
      src/or/directory.c

+ 3 - 0
ChangeLog

@@ -38,6 +38,9 @@ Changes in version 0.2.1.1-alpha - 2008-??-??
     - Add a malloc_good_size implementation to OpenBSD_malloc_linux.c,
       to avoid unused RAM in buffer chunks and memory pools.
     - Downgrade "sslv3 alert handshake failure" message to INFO.
+    - Only log guard node status when guard node status has changed.
+    - Downgrade the 3 most common "INFO" messages to "DEBUG".  This will make
+      "INFO" 75% less verbose.
 
   o Code simplifications and refactoring:
     - Refactor code using connection_ap_handshake_attach_circuit() to

+ 18 - 12
src/or/circuitbuild.c

@@ -755,8 +755,8 @@ circuit_extend(cell_t *cell, circuit_t *circ)
     char tmpbuf[INET_NTOA_BUF_LEN];
     in.s_addr = htonl(circ->n_addr);
     tor_inet_ntoa(&in,tmpbuf,sizeof(tmpbuf));
-    log_info(LD_CIRC|LD_OR,"Next router (%s:%d) not connected. Connecting.",
-             tmpbuf, circ->n_port);
+    log_debug(LD_CIRC|LD_OR,"Next router (%s:%d) not connected. Connecting.",
+              tmpbuf, circ->n_port);
 
     circ->n_conn_onionskin = tor_malloc(ONIONSKIN_CHALLENGE_LEN);
     memcpy(circ->n_conn_onionskin, onionskin, ONIONSKIN_CHALLENGE_LEN);
@@ -2169,8 +2169,9 @@ entry_guards_compute_status(void)
 {
   time_t now;
   int changed = 0;
-  int severity = LOG_INFO;
+  int severity = LOG_DEBUG;
   or_options_t *options;
+  const char **reasons;
   if (! entry_guards)
     return;
 
@@ -2178,6 +2179,7 @@ entry_guards_compute_status(void)
 
   now = time(NULL);
 
+  reasons = tor_malloc_zero(smartlist_len(entry_guards) * sizeof(char*));
   SMARTLIST_FOREACH(entry_guards, entry_guard_t *, entry,
     {
       routerinfo_t *r = router_get_by_digest(entry->identity);
@@ -2187,24 +2189,28 @@ entry_guards_compute_status(void)
 
       if (entry->bad_since)
         tor_assert(reason);
-
-      log_info(LD_CIRC, "Summary: Entry '%s' is %s, %s%s, and %s.",
-               entry->nickname,
-               entry->unreachable_since ? "unreachable" : "reachable",
-               entry->bad_since ? "unusable: " : "usable",
-               entry->bad_since ? reason : "",
-               entry_is_live(entry, 0, 1, 0) ? "live" : "not live");
+      reasons[entry_sl_idx] = reason;
     });
 
   if (remove_dead_entry_guards())
     changed = 1;
 
+  severity = changed ? LOG_DEBUG : LOG_INFO;
+
   if (changed) {
-    log_fn(severity, LD_CIRC, "    (%d/%d entry guards are usable/new)",
-           num_live_entry_guards(), smartlist_len(entry_guards));
+    SMARTLIST_FOREACH(entry_guards, entry_guard_t *, entry,
+        log_info(LD_CIRC, "Summary: Entry '%s' is %s, %s%s, and %s.",
+               entry->nickname,
+               entry->unreachable_since ? "unreachable" : "reachable",
+               entry->bad_since ? "unusable: " : "usable",
+               reasons[entry_sl_idx] ? reasons[entry_sl_idx] : "",
+               entry_is_live(entry, 0, 1, 0) ? "live" : "not live"));
+    log_info(LD_CIRC, "    (%d/%d entry guards are usable/new)",
+             num_live_entry_guards(), smartlist_len(entry_guards));
     log_entry_guards(LOG_INFO);
     entry_guards_changed();
   }
+  tor_free(reasons);
 }
 
 /** Called when a connection to an OR with the identity digest <b>digest</b>

+ 2 - 2
src/or/connection.c

@@ -1965,14 +1965,14 @@ connection_read_to_buf(connection_t *conn, int *max_to_read)
     switch (result) {
       case TOR_TLS_CLOSE:
       case TOR_TLS_ERROR_IO:
-        log_info(LD_NET,"TLS connection closed %son read. Closing. "
+        log_debug(LD_NET,"TLS connection closed %son read. Closing. "
                  "(Nickname %s, address %s",
                  result == TOR_TLS_CLOSE ? "cleanly " : "",
                  or_conn->nickname ? or_conn->nickname : "not set",
                  conn->address);
         return result;
       CASE_TOR_TLS_ERROR_ANY_NONIO:
-        log_info(LD_NET,"tls error [%s]. breaking (nickname %s, address %s).",
+        log_debug(LD_NET,"tls error [%s]. breaking (nickname %s, address %s).",
                  tor_tls_err_to_string(result),
                  or_conn->nickname ? or_conn->nickname : "not set",
                  conn->address);

+ 2 - 2
src/or/directory.c

@@ -2209,7 +2209,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
     dlen = compressed ? d->dir_z_len : d->dir_len;
 
     if (global_write_bucket_low(TO_CONN(conn), dlen, 1)) {
-      log_info(LD_DIRSERV,
+      log_debug(LD_DIRSERV,
                "Client asked for the mirrored directory, but we've been "
                "writing too many bytes lately. Sending 503 Dir busy.");
       write_http_status_line(conn, 503, "Directory busy, try again later");
@@ -2314,7 +2314,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
 
     dlen = dirserv_estimate_data_size(dir_fps, 0, compressed);
     if (global_write_bucket_low(TO_CONN(conn), dlen, 2)) {
-      log_info(LD_DIRSERV,
+      log_debug(LD_DIRSERV,
                "Client asked for network status lists, but we've been "
                "writing too many bytes lately. Sending 503 Dir busy.");
       write_http_status_line(conn, 503, "Directory busy, try again later");