mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
make circ->onionskin a pointer, not a static array. moria2 was using
125000 circuit_t's after it had been up for a few weeks, which translates to 20+ megs of wasted space. svn:r5333
This commit is contained in:
parent
bf2be9abd7
commit
44b3f3060a
@ -414,10 +414,12 @@ circuit_n_conn_done(connection_t *or_conn, int status)
|
||||
}
|
||||
} else {
|
||||
/* pull the create cell out of circ->onionskin, and send it */
|
||||
tor_assert(circ->onionskin);
|
||||
if (circuit_deliver_create_cell(circ,CELL_CREATE,circ->onionskin) < 0) {
|
||||
circuit_mark_for_close(circ);
|
||||
continue;
|
||||
}
|
||||
tor_free(circ->onionskin);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -522,7 +524,7 @@ circuit_send_next_onion_skin(circuit_t *circ)
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
/* We are not an OR, and we building the first hop of a circuit to
|
||||
/* We are not an OR, and we're building the first hop of a circuit to
|
||||
* a new OR: we can be speedy. */
|
||||
cell_type = CELL_CREATE_FAST;
|
||||
memset(payload, 0, sizeof(payload));
|
||||
@ -643,6 +645,7 @@ circuit_extend(cell_t *cell, circuit_t *circ)
|
||||
info(LD_CIRC|LD_OR,"Next router (%s:%d) not connected. Connecting.",
|
||||
tmpbuf, circ->n_port);
|
||||
|
||||
circ->onionskin = tor_malloc(ONIONSKIN_CHALLENGE_LEN);
|
||||
memcpy(circ->onionskin, onionskin, ONIONSKIN_CHALLENGE_LEN);
|
||||
circ->state = CIRCUIT_STATE_OR_WAIT;
|
||||
|
||||
@ -1197,6 +1200,8 @@ choose_good_exit_server_general(routerlist_t *dir, int need_uptime,
|
||||
smartlist_subtract(sl,excludedexits);
|
||||
if (options->StrictExitNodes || smartlist_overlap(sl,preferredexits))
|
||||
smartlist_intersect(sl,preferredexits);
|
||||
/* XXX sometimes the above results in null, when the requested
|
||||
* exit node is down. we should pick it anyway. */
|
||||
router = routerlist_sl_choose_by_bandwidth(sl);
|
||||
if (router)
|
||||
break;
|
||||
|
@ -250,6 +250,7 @@ circuit_free(circuit_t *circ)
|
||||
circuit_free_cpath_node(circ->build_state->pending_final_cpath);
|
||||
}
|
||||
tor_free(circ->build_state);
|
||||
tor_free(circ->onionskin);
|
||||
circuit_free_cpath(circ->cpath);
|
||||
if (circ->rend_splice) {
|
||||
circ->rend_splice->rend_splice = NULL;
|
||||
@ -792,6 +793,7 @@ assert_circuit_ok(const circuit_t *c)
|
||||
tor_assert(c->deliver_window >= 0);
|
||||
tor_assert(c->package_window >= 0);
|
||||
if (c->state == CIRCUIT_STATE_OPEN) {
|
||||
tor_assert(!c->onionskin);
|
||||
if (c->cpath) {
|
||||
tor_assert(CIRCUIT_IS_ORIGIN(c));
|
||||
tor_assert(!c->n_crypto);
|
||||
|
@ -200,6 +200,7 @@ command_process_create_cell(cell_t *cell, connection_t *conn)
|
||||
circ->purpose = CIRCUIT_PURPOSE_OR;
|
||||
circ->state = CIRCUIT_STATE_ONIONSKIN_PENDING;
|
||||
if (cell->command == CELL_CREATE) {
|
||||
circ->onionskin = tor_malloc(ONIONSKIN_CHALLENGE_LEN);
|
||||
memcpy(circ->onionskin, cell->payload, ONIONSKIN_CHALLENGE_LEN);
|
||||
|
||||
/* hand it off to the cpuworkers, and then return */
|
||||
|
@ -428,6 +428,7 @@ assign_to_cpuworker(connection_t *cpuworker, uint8_t question_type,
|
||||
|
||||
if (question_type == CPUWORKER_TASK_ONION) {
|
||||
circ = task;
|
||||
tor_assert(circ->onionskin);
|
||||
|
||||
if (num_cpuworkers_busy == num_cpuworkers) {
|
||||
debug(LD_OR,"No idle cpuworkers. Queuing.");
|
||||
@ -453,6 +454,7 @@ assign_to_cpuworker(connection_t *cpuworker, uint8_t question_type,
|
||||
connection_write_to_buf((char*)&question_type, 1, cpuworker);
|
||||
connection_write_to_buf(tag, sizeof(tag), cpuworker);
|
||||
connection_write_to_buf(circ->onionskin, ONIONSKIN_CHALLENGE_LEN, cpuworker);
|
||||
tor_free(circ->onionskin);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1068,8 +1068,11 @@ struct circuit_t {
|
||||
*/
|
||||
crypt_path_t *cpath;
|
||||
|
||||
/** For storage while passing to cpuworker, or while n_conn is pending. */
|
||||
char onionskin[ONIONSKIN_CHALLENGE_LEN];
|
||||
/** For storage while passing to cpuworker (state
|
||||
* CIRCUIT_STATE_ONIONSKIN_PENDING), or while n_conn is pending
|
||||
* (state CIRCUIT_STATE_OR_WAIT). When defined, it is always
|
||||
* length ONIONSKIN_CHALLENGE_LEN. */
|
||||
char *onionskin;
|
||||
|
||||
char handshake_digest[DIGEST_LEN]; /**< Stores KH for intermediate hops. */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user