diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-04-09 11:50:20 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-04-09 11:50:20 -0400 |
commit | 80031db32abebaf4d0a91c01db258fcdbd54a471 (patch) | |
tree | 19bd6af4959027109db5c83ecb0472ba51ab8404 /src/core/or/channel.c | |
parent | 11fbd1f064751e38ccd79e7823adb688b1293e59 (diff) | |
parent | 75aba30abf50b918ef2188354176bbc2ae59c99c (diff) | |
download | tor-80031db32abebaf4d0a91c01db258fcdbd54a471.tar.gz tor-80031db32abebaf4d0a91c01db258fcdbd54a471.zip |
Merge remote-tracking branch 'tor-github/pr/1801/head'
Diffstat (limited to 'src/core/or/channel.c')
-rw-r--r-- | src/core/or/channel.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/core/or/channel.c b/src/core/or/channel.c index 6fd33feda7..75054aa0c4 100644 --- a/src/core/or/channel.c +++ b/src/core/or/channel.c @@ -2359,19 +2359,22 @@ channel_is_better(channel_t *a, channel_t *b) /** * Get a channel to extend a circuit. * - * Pick a suitable channel to extend a circuit to given the desired digest - * the address we believe is correct for that digest; this tries to see - * if we already have one for the requested endpoint, but if there is no good - * channel, set *msg_out to a message describing the channel's state - * and our next action, and set *launch_out to a boolean indicated whether - * the caller should try to launch a new channel with channel_connect(). - */ -channel_t * -channel_get_for_extend(const char *rsa_id_digest, - const ed25519_public_key_t *ed_id, - const tor_addr_t *target_addr, - const char **msg_out, - int *launch_out) + * Given the desired relay identity, pick a suitable channel to extend a + * circuit to the target address requsted by the client. Search for an + * existing channel for the requested endpoint. Make sure the channel is + * usable for new circuits, and matches the target address. + * + * Try to return the best channel. But if there is no good channel, set + * *msg_out to a message describing the channel's state and our next action, + * and set *launch_out to a boolean indicated whether the caller should try to + * launch a new channel with channel_connect(). + */ +MOCK_IMPL(channel_t *, +channel_get_for_extend,(const char *rsa_id_digest, + const ed25519_public_key_t *ed_id, + const tor_addr_t *target_addr, + const char **msg_out, + int *launch_out)) { channel_t *chan, *best = NULL; int n_inprogress_goodaddr = 0, n_old = 0; @@ -2382,9 +2385,7 @@ channel_get_for_extend(const char *rsa_id_digest, chan = channel_find_by_remote_identity(rsa_id_digest, ed_id); - /* Walk the list, unrefing the old one and refing the new at each - * iteration. - */ + /* Walk the list of channels */ for (; chan; chan = channel_next_with_rsa_identity(chan)) { tor_assert(tor_memeq(chan->identity_digest, rsa_id_digest, DIGEST_LEN)); @@ -2819,8 +2820,8 @@ channel_get_actual_remote_address(channel_t *chan) * Subsequent calls to channel_get_{actual,canonical}_remote_{address,descr} * may invalidate the return value from this function. */ -const char * -channel_get_canonical_remote_descr(channel_t *chan) +MOCK_IMPL(const char *, +channel_get_canonical_remote_descr,(channel_t *chan)) { tor_assert(chan); tor_assert(chan->get_remote_descr); |