summaryrefslogtreecommitdiff
path: root/src/common/tortls.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-01-15 21:21:05 +0000
committerNick Mathewson <nickm@torproject.org>2007-01-15 21:21:05 +0000
commit380f8983c7e32dd26e8746f6cf75d12d08f962f7 (patch)
tree128c9c6149c3c173f9e12450b56cb7237eb2846d /src/common/tortls.c
parentead35ef9440a4d20a559441b2c6779954d3c02d5 (diff)
downloadtor-380f8983c7e32dd26e8746f6cf75d12d08f962f7.tar.gz
tor-380f8983c7e32dd26e8746f6cf75d12d08f962f7.zip
r11966@Kushana: nickm | 2007-01-15 16:12:17 -0500
Tidy up ORCONN reason patch from Mike Perry. Changes: make some of the handling of TLS error codes less error prone. Enforce house style wrt spaces. Make it compile with --enable-gcc-warnings. Only set or_conn->tls_error in the case of an actual error. Add a changelog entry. svn:r9355
Diffstat (limited to 'src/common/tortls.c')
-rw-r--r--src/common/tortls.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/common/tortls.c b/src/common/tortls.c
index f7e48b22f5..b93d761b0c 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -73,8 +73,8 @@ static tor_tls_context_t *global_tls_context = NULL;
static int tls_library_is_initialized = 0;
/* Module-internal error codes. */
-#define _TOR_TLS_SYSCALL -10
-#define _TOR_TLS_ZERORETURN -9
+#define _TOR_TLS_SYSCALL (_MIN_TOR_TLS_ERROR_VAL - 2)
+#define _TOR_TLS_ZERORETURN (_MIN_TOR_TLS_ERROR_VAL - 1)
/* These functions are declared in crypto.c but not exported. */
EVP_PKEY *_crypto_pk_env_get_evp_pkey(crypto_pk_env_t *env, int private);
@@ -104,9 +104,10 @@ tls_log_errors(int severity, const char *doing)
}
static int
-tor_errno_to_tls_error(int e) {
+tor_errno_to_tls_error(int e)
+{
#if defined(MS_WINDOWS) && !defined(USE_BSOCKETS)
- switch(e) {
+ switch (e) {
case WSAECONNRESET: // most common
return TOR_TLS_ERROR_CONNRESET;
case WSAETIMEDOUT:
@@ -119,8 +120,8 @@ tor_errno_to_tls_error(int e) {
default:
return TOR_TLS_ERROR_MISC;
}
-#else
- switch(e) {
+#else
+ switch (e) {
case ECONNRESET: // most common
return TOR_TLS_ERROR_CONNRESET;
case ETIMEDOUT:
@@ -182,6 +183,8 @@ tor_tls_get_error(tor_tls_t *tls, int r, int extra,
return _TOR_TLS_ZERORETURN;
log(severity, LD_NET, "TLS error: Zero return");
tls_log_errors(severity, doing);
+ /* XXXX Actually, a 'zero return' error has a pretty specific meaning:
+ * the connection has been closed cleanly. */
return TOR_TLS_ERROR_MISC;
default:
tls_log_errors(severity, doing);