summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-01-16 15:30:20 -0500
committerNick Mathewson <nickm@torproject.org>2013-01-16 15:30:20 -0500
commit9bd811b337f1316d26e5553f4d8720c9353d1b5d (patch)
treed28006f2e2fc5d6ee938b608f1baaa30ecc131bd /src/common
parent65e6e68981d9910c5f78f2cfed6c59cbee1494c7 (diff)
downloadtor-9bd811b337f1316d26e5553f4d8720c9353d1b5d.tar.gz
tor-9bd811b337f1316d26e5553f4d8720c9353d1b5d.zip
Refactor: Use SOCK_ERRNO to avoid some #ifdef _WIN32s
Fixes ticket 6302
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tortls.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 1d093dfcba..93761f596a 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -359,35 +359,19 @@ tls_log_errors(tor_tls_t *tls, int severity, int domain, const char *doing)
static int
tor_errno_to_tls_error(int e)
{
-#if defined(_WIN32)
switch (e) {
- case WSAECONNRESET: // most common
+ case SOCK_ERRNO(ECONNRESET): // most common
return TOR_TLS_ERROR_CONNRESET;
- case WSAETIMEDOUT:
+ case SOCK_ERRNO(ETIMEDOUT):
return TOR_TLS_ERROR_TIMEOUT;
- case WSAENETUNREACH:
- case WSAEHOSTUNREACH:
+ case SOCK_ERRNO(EHOSTUNREACH):
+ case SOCK_ERRNO(ENETUNREACH):
return TOR_TLS_ERROR_NO_ROUTE;
- case WSAECONNREFUSED:
+ case SOCK_ERRNO(ECONNREFUSED):
return TOR_TLS_ERROR_CONNREFUSED; // least common
default:
return TOR_TLS_ERROR_MISC;
}
-#else
- switch (e) {
- case ECONNRESET: // most common
- return TOR_TLS_ERROR_CONNRESET;
- case ETIMEDOUT:
- return TOR_TLS_ERROR_TIMEOUT;
- case EHOSTUNREACH:
- case ENETUNREACH:
- return TOR_TLS_ERROR_NO_ROUTE;
- case ECONNREFUSED:
- return TOR_TLS_ERROR_CONNREFUSED; // least common
- default:
- return TOR_TLS_ERROR_MISC;
- }
-#endif
}
/** Given a TOR_TLS_* error code, return a string equivalent. */