]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
r16523@catbus: nickm | 2007-11-07 11:35:49 -0500
authorNick Mathewson <nickm@torproject.org>
Wed, 7 Nov 2007 16:37:08 +0000 (16:37 +0000)
committerNick Mathewson <nickm@torproject.org>
Wed, 7 Nov 2007 16:37:08 +0000 (16:37 +0000)
 Improve "tls error. breaking" message a little.

svn:r12411

ChangeLog
src/common/tortls.c
src/common/tortls.h
src/or/connection.c

index 6bf665e6b3ac206c057930b3d76d297a21c83454..c2b29395326adc47d083d0d4325b094a270c0b32 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -66,6 +66,7 @@ Changes in version 0.2.0.10-alpha - 2007-11-0?
       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
index 4b46f9d9d20d24d42d60836b2efe5608163dc64b..5b902c9e9a464eeeef0844e4b018c514e9f1e00d 100644 (file)
@@ -145,6 +145,26 @@ tor_errno_to_tls_error(int e)
 #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
 
index 3a58cc279521f3dc63b35ecbfd750db2896af904..d30a154fa27151610ce6411ff9d5267a685c2f0a 100644 (file)
@@ -21,6 +21,7 @@ typedef struct tor_tls_t tor_tls_t;
 /* 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 @@ typedef struct tor_tls_t tor_tls_t;
 #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,
index 382802e3f3ec28d036b566f65a7ee1b5916099ac..0dd2f9e43dd701445e2240f9d17107bc45c47426 100644 (file)
@@ -1917,7 +1917,8 @@ connection_read_to_buf(connection_t *conn, int *max_to_read)
                  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;