Commit 0c047b87 authored by Roger Dingledine's avatar Roger Dingledine
Browse files

polish r9933-r9994


svn:r10335
parent a19d131e
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 *
 *     Generally, a memory pool is an allocation strategy optimized for large
 *     numbers of identically-sized objects.  Rather than the elaborate arena
 *     and coalescing strategeis you need to get good performance for a
 *     and coalescing strategies you need to get good performance for a
 *     general-purpose malloc(), pools use a series of large memory "chunks",
 *     each of which is carved into a bunch of smaller "items" or
 *     "allocations".
@@ -33,7 +33,7 @@
 *
 *     I wrote this after looking at 3 or 4 other pooling allocators, but
 *     without copying.  The strategy this most resembles (which is funny,
 *     since that's the one I looked at longest ago) the pool allocator
 *     since that's the one I looked at longest ago) is the pool allocator
 *     underlying Python's obmalloc code.  Major differences from obmalloc's
 *     pools are:
 *       - We don't even try to be threadsafe.
@@ -93,7 +93,7 @@
/** Largest type that we need to ensure returned memory items are aligned to.
 * Change this to "double" if we need to be safe for structs with doubles. */
#define ALIGNMENT_TYPE void *
/** Increment that we need to align allocated  */
/** Increment that we need to align allocated. */
#define ALIGNMENT sizeof(ALIGNMENT_TYPE)
/** Largest memory chunk that we should allocate. */
#define MAX_CHUNK (8*(1L<<20))
@@ -128,14 +128,14 @@ struct mp_chunk_t {
  unsigned long magic; /**< Must be MP_CHUNK_MAGIC if this chunk is valid. */
  mp_chunk_t *next; /**< The next free, used, or full chunk in sequence. */
  mp_chunk_t *prev; /**< The previous free, used, or full chunk in sequence. */
  mp_pool_t *pool; /**< The pool that this chunk is part of */
  mp_pool_t *pool; /**< The pool that this chunk is part of. */
  /** First free item in the freelist for this chunk.  Note that this may be
   * NULL even if this chunk is not at capacity: if so, the free memory at
   * next_mem has not yet been carved into items.
   */
  mp_allocated_t *first_free;
  int n_allocated; /**< Number of currently allocated items in this chunk */
  int capacity; /**< Largest number of items that can be fit into this chunk */
  int n_allocated; /**< Number of currently allocated items in this chunk. */
  int capacity; /**< Largest number of items that can be fit into this chunk. */
  size_t mem_size; /**< Number of usable bytes in mem. */
  char *next_mem; /**< Pointer into part of <b>mem</b> not yet carved up. */
  char mem[1]; /**< Storage for this chunk. (Not actual size.) */
+1 −1
Original line number Diff line number Diff line
@@ -2081,7 +2081,7 @@ get_default_nickname(void)
  return out;
}

/** Release storage held by <b>options</b> */
/** Release storage held by <b>options</b>. */
static void
config_free(config_format_t *fmt, void *options)
{
+1 −1
Original line number Diff line number Diff line
@@ -215,7 +215,7 @@ connection_new(int type)
  return conn;
}

/** Create a link between <b>conn_a</b> and <b>conn_b</b> */
/** Create a link between <b>conn_a</b> and <b>conn_b</b>. */
void
connection_link_connections(connection_t *conn_a, connection_t *conn_b)
{
+9 −8
Original line number Diff line number Diff line
@@ -570,7 +570,7 @@ addressmap_ent_free(void *_ent)
  tor_free(ent);
}

/** Free storage held by a virtaddress_entry_t* entry in <b>ent</b> */
/** Free storage held by a virtaddress_entry_t* entry in <b>ent</b>. */
static void
addressmap_virtaddress_ent_free(void *_ent)
{
@@ -580,7 +580,7 @@ addressmap_virtaddress_ent_free(void *_ent)
  tor_free(ent);
}

/** Free storage held by a virtaddress_entry_t* entry in <b>ent</b> */
/** Free storage held by a virtaddress_entry_t* entry in <b>ent</b>. */
static void
addressmap_virtaddress_remove(const char *address, addressmap_entry_t *ent)
{
@@ -2094,8 +2094,9 @@ connection_ap_handshake_socks_reply(edge_connection_t *conn, char *reply,
  return;
}

/** A relay 'begin' cell has arrived, and either we are an exit hop
 * for the circuit, or we are the origin and it is a rendezvous begin.
/** A relay 'begin' or 'begin_dir' cell has arrived, and either we are
 * an exit hop for the circuit, or we are the origin and it is a
 * rendezvous begin.
 *
 * Launch a new exit connection and initialize things appropriately.
 *
@@ -2273,7 +2274,7 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)

  /* send it off to the gethostbyname farm */
  switch (dns_resolve(n_stream)) {
    case 1: /* resolve worked */
    case 1: /* resolve worked; now n_stream is attached to circ. */
      assert_circuit_ok(circ);
      log_debug(LD_EXIT,"about to call connection_exit_connect().");
      connection_exit_connect(n_stream);
@@ -2282,12 +2283,11 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
      end_payload[0] = END_STREAM_REASON_RESOLVEFAILED;
      relay_send_command_from_edge(rh.stream_id, circ, RELAY_COMMAND_END,
                                   end_payload, 1, NULL);
      /* n_stream got detached and freed. don't touch it. */
      /* n_stream got freed. don't touch it. */
      break;
    case 0: /* resolve added to pending list */
      /* add it into the linked list of resolving_streams on this circuit */
      assert_circuit_ok(circ);
      ;
      break;
  }
  return 0;
}
@@ -2466,6 +2466,7 @@ connection_exit_connect_dir(edge_connection_t *exitconn)
    return 0;
  }

  /* link exitconn to circ, now that we know we can use it. */
  exitconn->next_stream = circ->n_streams;
  circ->n_streams = exitconn;

+3 −0
Original line number Diff line number Diff line
@@ -120,6 +120,9 @@ connection_or_set_identity_digest(or_connection_t *conn, const char *digest)
/** Pack the cell_t host-order structure <b>src</b> into network-order
 * in the buffer <b>dest</b>. See tor-spec.txt for details about the
 * wire format.
 *
 * Note that this function doesn't touch <b>dst</b>-\>next: the caller
 * should set it or clear it as appropriate.
 */
void
cell_pack(packed_cell_t *dst, const cell_t *src)
Loading