[or-cvs] r12411: Improve "tls error. breaking" message a little. (in tor/trunk: . src/common src/or)

nickm at seul.org nickm at seul.org
Wed Nov 7 16:37:08 UTC 2007


Author: nickm
Date: 2007-11-07 11:37:08 -0500 (Wed, 07 Nov 2007)
New Revision: 12411

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/common/tortls.c
   tor/trunk/src/common/tortls.h
   tor/trunk/src/or/connection.c
Log:
 r16523 at catbus:  nickm | 2007-11-07 11:35:49 -0500
 Improve "tls error. breaking" message a little.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r16523] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-11-07 15:33:14 UTC (rev 12410)
+++ tor/trunk/ChangeLog	2007-11-07 16:37:08 UTC (rev 12411)
@@ -66,6 +66,7 @@
       an accepted-but-discarded descriptor upload.  Partially implements
       fix for bug 535.
     - Make the "not enough dir info yet" message better.
+    - Make the log message for "tls error. breaking." more useful.
 
   o Minor features (bridges):
     - If bridge users set UpdateBridgesFromAuthority, but the digest

Modified: tor/trunk/src/common/tortls.c
===================================================================
--- tor/trunk/src/common/tortls.c	2007-11-07 15:33:14 UTC (rev 12410)
+++ tor/trunk/src/common/tortls.c	2007-11-07 16:37:08 UTC (rev 12411)
@@ -145,6 +145,26 @@
 #endif
 }
 
+/** DOCDOC */
+const char *
+tor_tls_err_to_string(int err)
+{
+  if (err >= 0)
+    return "[Not an error.]";
+  switch (err) {
+    case TOR_TLS_ERROR_MISC: return "misc error";
+    case TOR_TLS_ERROR_IO: return "unexpected close";
+    case TOR_TLS_ERROR_CONNREFUSED: return "connection refused";
+    case TOR_TLS_ERROR_CONNRESET: return "connection reset";
+    case TOR_TLS_ERROR_NO_ROUTE: return "host unreachable";
+    case TOR_TLS_ERROR_TIMEOUT: return "connection timed out";
+    case TOR_TLS_CLOSE: return "closed";
+    case TOR_TLS_WANTREAD: return "want to read";
+    case TOR_TLS_WANTWRITE: return "want to write";
+    default: return "(unknown error code)";
+  }
+}
+
 #define CATCH_SYSCALL 1
 #define CATCH_ZERO    2
 

Modified: tor/trunk/src/common/tortls.h
===================================================================
--- tor/trunk/src/common/tortls.h	2007-11-07 15:33:14 UTC (rev 12410)
+++ tor/trunk/src/common/tortls.h	2007-11-07 16:37:08 UTC (rev 12411)
@@ -21,6 +21,7 @@
 /* Possible return values for most tor_tls_* functions. */
 #define _MIN_TOR_TLS_ERROR_VAL     -9
 #define TOR_TLS_ERROR_MISC         -9
+/* Rename to unexpected close or something. XXX020 */
 #define TOR_TLS_ERROR_IO           -8
 #define TOR_TLS_ERROR_CONNREFUSED  -7
 #define TOR_TLS_ERROR_CONNRESET    -6
@@ -45,6 +46,7 @@
 #define TOR_TLS_RANDOM_LEN 32
 
 #define TOR_TLS_IS_ERROR(rv) ((rv) < TOR_TLS_CLOSE)
+const char *tor_tls_err_to_string(int err);
 
 void tor_tls_free_all(void);
 int tor_tls_context_new(crypto_pk_env_t *rsa,

Modified: tor/trunk/src/or/connection.c
===================================================================
--- tor/trunk/src/or/connection.c	2007-11-07 15:33:14 UTC (rev 12410)
+++ tor/trunk/src/or/connection.c	2007-11-07 16:37:08 UTC (rev 12411)
@@ -1917,7 +1917,8 @@
                  conn->address);
         return result;
       CASE_TOR_TLS_ERROR_ANY:
-        log_info(LD_NET,"tls error. breaking (nickname %s, address %s).",
+        log_info(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);
         return result;



More information about the tor-commits mailing list