summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/onion_client.c7
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 */
210static int random_path(const Onion_Client *onion_c, Onion_Client_Paths *onion_paths, uint32_t pathnum, Onion_Path *path) 210static 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;