diff options
author | irungentoo <irungentoo@gmail.com> | 2015-06-10 22:39:11 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-06-10 22:39:11 -0400 |
commit | ae2caad98245bdac24ea05685a730022d611576e (patch) | |
tree | 35404f0995383b83f6c2bbd629690a5dc77e836a /toxcore | |
parent | 8ac74ebf47ba8268ec293fca11942e33c19d298b (diff) |
Use real path num in onion client.
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/onion_client.c | 7 |
1 files changed, 5 insertions, 2 deletions
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 | |||
209 | */ | 209 | */ |
210 | static int random_path(const Onion_Client *onion_c, Onion_Client_Paths *onion_paths, uint32_t pathnum, Onion_Path *path) | 210 | static int random_path(const Onion_Client *onion_c, Onion_Client_Paths *onion_paths, uint32_t pathnum, Onion_Path *path) |
211 | { | 211 | { |
212 | if (pathnum >= NUMBER_ONION_PATHS) | 212 | if (pathnum == ~0) { |
213 | pathnum = rand() % NUMBER_ONION_PATHS; | 213 | pathnum = rand() % NUMBER_ONION_PATHS; |
214 | } else { | ||
215 | pathnum = pathnum % NUMBER_ONION_PATHS; | ||
216 | } | ||
214 | 217 | ||
215 | if ((onion_paths->last_path_success[pathnum] + ONION_PATH_TIMEOUT < onion_paths->last_path_used[pathnum] | 218 | if ((onion_paths->last_path_success[pathnum] + ONION_PATH_TIMEOUT < onion_paths->last_path_used[pathnum] |
216 | && onion_paths->last_path_used_times[pathnum] >= ONION_PATH_MAX_NO_RESPONSE_USES) | 219 | && 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 | |||
277 | } | 280 | } |
278 | } | 281 | } |
279 | 282 | ||
280 | return path_num % NUMBER_ONION_PATHS; | 283 | return path_num; |
281 | } | 284 | } |
282 | 285 | ||
283 | return ~0; | 286 | return ~0; |