[or-cvs] r17827: {tor} Remove some code that is #ifdefed out, and that we no longer (in tor/trunk/src: common or)

nickm at seul.org nickm at seul.org
Tue Dec 30 04:16:49 UTC 2008


Author: nickm
Date: 2008-12-29 23:16:49 -0500 (Mon, 29 Dec 2008)
New Revision: 17827

Modified:
   tor/trunk/src/common/address.c
   tor/trunk/src/common/compat.c
   tor/trunk/src/common/compat.h
   tor/trunk/src/common/log.c
   tor/trunk/src/common/mempool.c
   tor/trunk/src/common/tortls.c
   tor/trunk/src/or/buffers.c
   tor/trunk/src/or/onion.c
Log:
Remove some code that is #ifdefed out, and that we no longer seem to use, if we ever did.

Modified: tor/trunk/src/common/address.c
===================================================================
--- tor/trunk/src/common/address.c	2008-12-30 04:08:45 UTC (rev 17826)
+++ tor/trunk/src/common/address.c	2008-12-30 04:16:49 UTC (rev 17827)
@@ -560,22 +560,6 @@
 
   v4map = tor_addr_is_v4(addr_out);
 
-/*
-#ifdef ALWAYS_V6_MAP
-  if (v_family == AF_INET) {
-    v_family = AF_INET6;
-    IN_ADDR6(addr_out).s6_addr32[3] = IN6_ADDRESS(addr_out).s_addr;
-    memset(&IN6_ADDRESS(addr_out), 0, 10);
-    IN_ADDR6(addr_out).s6_addr16[5] = 0xffff;
-  }
-#else
-  if (v_family == AF_INET6 && v4map) {
-    v_family = AF_INET;
-    IN4_ADDRESS((addr_out).s_addr = IN6_ADDRESS(addr_out).s6_addr32[3];
-  }
-#endif
-*/
-
   /* Parse mask */
   if (maskbits_out) {
     int bits = 0;

Modified: tor/trunk/src/common/compat.c
===================================================================
--- tor/trunk/src/common/compat.c	2008-12-30 04:08:45 UTC (rev 17826)
+++ tor/trunk/src/common/compat.c	2008-12-30 04:16:49 UTC (rev 17827)
@@ -87,10 +87,6 @@
 #include <sys/file.h>
 #endif
 
-#ifdef USE_BSOCKETS
-#include <bsocket.h>
-#endif
-
 #include "log.h"
 #include "util.h"
 #include "container.h"
@@ -630,9 +626,7 @@
    * tor_close_socket to close sockets, and always using close() on
    * files.
    */
-#ifdef USE_BSOCKETS
-  r = bclose(s);
-#elif defined(MS_WINDOWS)
+#if defined(MS_WINDOWS)
   r = closesocket(s);
 #else
   r = close(s);
@@ -718,7 +712,7 @@
 void
 set_socket_nonblocking(int socket)
 {
-#if defined(MS_WINDOWS) && !defined(USE_BSOCKETS)
+#if defined(MS_WINDOWS)
   unsigned long nonblocking = 1;
   ioctlsocket(socket, FIONBIO, (unsigned long*) &nonblocking);
 #else
@@ -761,8 +755,6 @@
     }
   }
   return r < 0 ? -errno : r;
-#elif defined(USE_BSOCKETS)
-  return bsocketpair(family, type, protocol, fd);
 #else
     /* This socketpair does not work when localhost is down. So
      * it's really not the same thing at all. But it's close enough
@@ -2082,7 +2074,7 @@
  * should call tor_socket_errno <em>at most once</em> on the failing
  * socket to get the error.
  */
-#if defined(MS_WINDOWS) && !defined(USE_BSOCKETS)
+#if defined(MS_WINDOWS)
 int
 tor_socket_errno(int sock)
 {
@@ -2098,7 +2090,7 @@
 }
 #endif
 
-#if defined(MS_WINDOWS) && !defined(USE_BSOCKETS)
+#if defined(MS_WINDOWS)
 #define E(code, s) { code, (s " [" #code " ]") }
 struct { int code; const char *msg; } windows_socket_errors[] = {
   E(WSAEINTR, "Interrupted function call"),

Modified: tor/trunk/src/common/compat.h
===================================================================
--- tor/trunk/src/common/compat.h	2008-12-30 04:08:45 UTC (rev 17826)
+++ tor/trunk/src/common/compat.h	2008-12-30 04:16:49 UTC (rev 17827)
@@ -324,13 +324,8 @@
 int tor_accept_socket(int sockfd, struct sockaddr *addr, socklen_t *len);
 int get_n_open_sockets(void);
 
-#ifdef USE_BSOCKETS
-#define tor_socket_send(s, buf, len, flags) bsend(s, buf, len, flags)
-#define tor_socket_recv(s, buf, len, flags) brecv(s, buf, len, flags)
-#else
 #define tor_socket_send(s, buf, len, flags) send(s, buf, len, flags)
 #define tor_socket_recv(s, buf, len, flags) recv(s, buf, len, flags)
-#endif
 
 /* Define struct in6_addr on platforms that do not have it.  Generally,
  * these platforms are ones without IPv6 support, but we want to have
@@ -403,7 +398,7 @@
  * errnos against expected values, and use tor_socket_errno to find
  * the actual errno after a socket operation fails.
  */
-#if defined(MS_WINDOWS) && !defined(USE_BSOCKETS)
+#if defined(MS_WINDOWS)
 /** Return true if e is EAGAIN or the local equivalent. */
 #define ERRNO_IS_EAGAIN(e)           ((e) == EAGAIN || (e) == WSAEWOULDBLOCK)
 /** Return true if e is EINPROGRESS or the local equivalent. */

Modified: tor/trunk/src/common/log.c
===================================================================
--- tor/trunk/src/common/log.c	2008-12-30 04:08:45 UTC (rev 17826)
+++ tor/trunk/src/common/log.c	2008-12-30 04:16:49 UTC (rev 17827)
@@ -95,12 +95,9 @@
   }
 }
 
-#define USE_LOG_MUTEX
-
-#ifdef USE_LOG_MUTEX
 /** A mutex to guard changes to logfiles and logging. */
 static tor_mutex_t *log_mutex = NULL;
-#endif
+
 /** Linked list of logfile_t. */
 static logfile_t *logfiles = NULL;
 #ifdef HAVE_SYSLOG_H
@@ -109,15 +106,10 @@
 static int syslog_count = 0;
 #endif
 
-#ifdef USE_LOG_MUTEX
 #define LOCK_LOGS() STMT_BEGIN                                          \
   tor_mutex_acquire(log_mutex);                                         \
   STMT_END
 #define UNLOCK_LOGS() STMT_BEGIN tor_mutex_release(log_mutex); STMT_END
-#else
-#define LOCK_LOGS() STMT_NIL
-#define UNLOCK_LOGS() STMT_NIL
-#endif
 
 /** What's the lowest log level anybody cares about?  Checking this lets us
  * bail out early from log_debug if we aren't debugging.  */

Modified: tor/trunk/src/common/mempool.c
===================================================================
--- tor/trunk/src/common/mempool.c	2008-12-30 04:08:45 UTC (rev 17826)
+++ tor/trunk/src/common/mempool.c	2008-12-30 04:16:49 UTC (rev 17827)
@@ -12,8 +12,6 @@
 #define MEMPOOL_PRIVATE
 #include "mempool.h"
 
-#define LAZY_CHUNK_SORT
-
 /* OVERVIEW:
  *
  *     This is an implementation of memory pools for Tor cells.  It may be
@@ -407,7 +405,6 @@
   return pool;
 }
 
-#ifdef LAZY_CHUNK_SORT
 /** Helper function for qsort: used to sort pointers to mp_chunk_t into
  * descending order of fullness. */
 static int
@@ -449,17 +446,8 @@
   }
   chunks[n-1]->next = NULL;
   FREE(chunks);
-#if 0
-  inverted = 0;
-  for (chunk = pool->used_chunks; chunk; chunk = chunk->next) {
-    if (chunk->next) {
-      ASSERT(chunk->next->n_allocated <= chunk->n_allocated);
-    }
-  }
-#endif
   mp_pool_assert_ok(pool);
 }
-#endif
 
 /** If there are more than <b>n</b> empty chunks in <b>pool</b>, free the
  * excess ones that have been empty for the longest. If
@@ -471,9 +459,7 @@
 {
   mp_chunk_t *chunk, **first_to_free;
 
-#ifdef LAZY_CHUNK_SORT
   mp_pool_sort_used_chunks(pool);
-#endif
   ASSERT(n_to_keep >= 0);
 
   if (keep_recently_used) {

Modified: tor/trunk/src/common/tortls.c
===================================================================
--- tor/trunk/src/common/tortls.c	2008-12-30 04:08:45 UTC (rev 17826)
+++ tor/trunk/src/common/tortls.c	2008-12-30 04:16:49 UTC (rev 17827)
@@ -199,7 +199,7 @@
 static int
 tor_errno_to_tls_error(int e)
 {
-#if defined(MS_WINDOWS) && !defined(USE_BSOCKETS)
+#if defined(MS_WINDOWS)
   switch (e) {
     case WSAECONNRESET: // most common
       return TOR_TLS_ERROR_CONNRESET;
@@ -839,11 +839,7 @@
   if (!isServer)
     rectify_client_ciphers(&result->ssl->cipher_list);
   result->socket = sock;
-#ifdef USE_BSOCKETS
-  bio = BIO_new_bsocket(sock, BIO_NOCLOSE);
-#else
   bio = BIO_new_socket(sock, BIO_NOCLOSE);
-#endif
   if (! bio) {
     tls_log_errors(NULL, LOG_WARN, "opening BIO");
     SSL_free(result->ssl);

Modified: tor/trunk/src/or/buffers.c
===================================================================
--- tor/trunk/src/or/buffers.c	2008-12-30 04:08:45 UTC (rev 17826)
+++ tor/trunk/src/or/buffers.c	2008-12-30 04:16:49 UTC (rev 17827)
@@ -23,7 +23,6 @@
 #endif
 
 //#define PARANOIA
-//#define NOINLINE
 
 #ifdef PARANOIA
 /** Helper: If PARANOIA is defined, assert that the buffer in local variable
@@ -33,11 +32,6 @@
 #define check() STMT_NIL
 #endif
 
-#ifdef NOINLINE
-#undef INLINE
-#define INLINE
-#endif
-
 /* Implementation notes:
  *
  * After flirting with memmove, and dallying with ring-buffers, we're finally

Modified: tor/trunk/src/or/onion.c
===================================================================
--- tor/trunk/src/or/onion.c	2008-12-30 04:08:45 UTC (rev 17826)
+++ tor/trunk/src/or/onion.c	2008-12-30 04:16:49 UTC (rev 17827)
@@ -187,21 +187,6 @@
   if (crypto_dh_get_public(dh, challenge, dhbytes))
     goto err;
 
-#ifdef DEBUG_ONION_SKINS
-#define PA(a,n) \
-  { int _i; for (_i = 0; _i<n; ++_i) printf("%02x ",((int)(a)[_i])&0xFF); }
-
-  printf("Client: client g^x:");
-  PA(challenge+16,3);
-  printf("...");
-  PA(challenge+141,3);
-  puts("");
-
-  printf("Client: client symkey:");
-  PA(challenge+0,16);
-  puts("");
-#endif
-
   note_crypto_pk_op(ENC_ONIONSKIN);
 
   /* set meeting point, meeting cookie, etc here. Leave zero for now. */
@@ -269,14 +254,6 @@
     goto err;
   }
 
-#ifdef DEBUG_ONION_SKINS
-  printf("Server: server g^y:");
-  PA(handshake_reply_out+0,3);
-  printf("...");
-  PA(handshake_reply_out+125,3);
-  puts("");
-#endif
-
   key_material_len = DIGEST_LEN+key_out_len;
   key_material = tor_malloc(key_material_len);
   len = crypto_dh_compute_secret(dh, challenge, DH_KEY_LEN,
@@ -292,15 +269,6 @@
   /* use the rest of the key material for our shared keys, digests, etc */
   memcpy(key_out, key_material+DIGEST_LEN, key_out_len);
 
-#ifdef DEBUG_ONION_SKINS
-  printf("Server: key material:");
-  PA(key_material, DH_KEY_LEN);
-  puts("");
-  printf("Server: keys out:");
-  PA(key_out, key_out_len);
-  puts("");
-#endif
-
   memset(challenge, 0, sizeof(challenge));
   memset(key_material, 0, key_material_len);
   tor_free(key_material);
@@ -337,14 +305,6 @@
   size_t key_material_len;
   tor_assert(crypto_dh_get_bytes(handshake_state) == DH_KEY_LEN);
 
-#ifdef DEBUG_ONION_SKINS
-  printf("Client: server g^y:");
-  PA(handshake_reply+0,3);
-  printf("...");
-  PA(handshake_reply+125,3);
-  puts("");
-#endif
-
   key_material_len = DIGEST_LEN + key_out_len;
   key_material = tor_malloc(key_material_len);
   len = crypto_dh_compute_secret(handshake_state, handshake_reply, DH_KEY_LEN,
@@ -362,12 +322,6 @@
   /* use the rest of the key material for our shared keys, digests, etc */
   memcpy(key_out, key_material+DIGEST_LEN, key_out_len);
 
-#ifdef DEBUG_ONION_SKINS
-  printf("Client: keys out:");
-  PA(key_out, key_out_len);
-  puts("");
-#endif
-
   memset(key_material, 0, key_material_len);
   tor_free(key_material);
   return 0;



More information about the tor-commits mailing list