Commit 52932d6f authored by Nick Mathewson's avatar Nick Mathewson 🥔
Browse files

Remove some code that is #ifdefed out, and that we no longer seem to use, if we ever did.

svn:r17827
parent ffe22fab
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -560,22 +560,6 @@ tor_addr_parse_mask_ports(const char *s, tor_addr_t *addr_out,

  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;
+4 −12
Original line number Diff line number Diff line
@@ -87,10 +87,6 @@ const char compat_c_id[] =
#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(int s)
   * 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 @@ get_n_open_sockets(void)
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 @@ tor_socketpair(int family, int type, int protocol, int fd[2])
    }
  }
  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 @@ tor_threads_init(void)
 * 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 @@ tor_socket_errno(int sock)
}
#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"),
+1 −6
Original line number Diff line number Diff line
@@ -324,13 +324,8 @@ int tor_open_socket(int domain, int type, int protocol);
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 @@ int network_init(void);
 * 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. */
+1 −9
Original line number Diff line number Diff line
@@ -95,12 +95,9 @@ should_log_function_name(log_domain_mask_t domain, int severity)
  }
}

#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 logfile_t *logfiles = NULL;
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.  */
+0 −14
Original line number Diff line number Diff line
@@ -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 @@ mp_pool_new(size_t item_size, size_t chunk_capacity)
  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 @@ mp_pool_sort_used_chunks(mp_pool_t *pool)
  }
  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_pool_clean(mp_pool_t *pool, int n_to_keep, int keep_recently_used)
{
  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) {
Loading