From ae2caad98245bdac24ea05685a730022d611576e Mon Sep 17 00:00:00 2001 From: irungentoo Date: Wed, 10 Jun 2015 22:39:11 -0400 Subject: Use real path num in onion client. --- toxcore/onion_client.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'toxcore') diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 6575f632..524792ef 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c @@ -209,8 +209,11 @@ static int is_path_used(const Onion_Client_Paths *onion_paths, const Node_format */ static int random_path(const Onion_Client *onion_c, Onion_Client_Paths *onion_paths, uint32_t pathnum, Onion_Path *path) { - if (pathnum >= NUMBER_ONION_PATHS) + if (pathnum == ~0) { pathnum = rand() % NUMBER_ONION_PATHS; + } else { + pathnum = pathnum % NUMBER_ONION_PATHS; + } if ((onion_paths->last_path_success[pathnum] + ONION_PATH_TIMEOUT < onion_paths->last_path_used[pathnum] && onion_paths->last_path_used_times[pathnum] >= ONION_PATH_MAX_NO_RESPONSE_USES) @@ -277,7 +280,7 @@ static uint32_t set_path_timeouts(Onion_Client *onion_c, uint32_t num, uint32_t } } - return path_num % NUMBER_ONION_PATHS; + return path_num; } return ~0; -- cgit v1.2.3