From 61dac5c979d236d4256eaca718984270a5524ff2 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Sat, 27 Dec 2014 23:32:30 -0500 Subject: [PATCH] onion_isconnected fix attempt. Try to make it more stable. --- toxcore/onion_client.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index d2fb9449..2e39762f 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c @@ -1419,10 +1419,16 @@ int onion_isconnected(const Onion_Client *onion_c) } } + unsigned int pnodes = onion_c->path_nodes_index; + + if (pnodes > MAX_ONION_CLIENTS) { + pnodes = MAX_ONION_CLIENTS; + } + /* Consider ourselves online if we are announced to half or more nodes we are connected to */ if (num && announced) { - if ((num / 2) <= announced) + if ((num / 2) <= announced && (pnodes / 2) <= num) return 1; }