summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
authorEvgeny Kurnevsky <kurnevsky@gmail.com>2019-02-19 12:17:35 +0300
committerRobin Lindén <dev@robinlinden.eu>2019-05-01 16:40:04 +0200
commitd26b11d0c263bd796762374154edc7386dd601d4 (patch)
treefceaca6d997e04ec90b75d2ae45433c0a155e9b1 /toxcore
parentb3100c977c58437b680d8c39aaa8f167aeecaa59 (diff)
Do not send the same packet to the same node twice.
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/DHT.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 6b2715ee..79925552 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -1986,7 +1986,6 @@ int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8_t *pack
1986 } 1986 }
1987 1987
1988 uint32_t sent = 0; 1988 uint32_t sent = 0;
1989 uint8_t friend_sent[MAX_FRIEND_CLIENTS] = {0};
1990 1989
1991 IP_Port ip_list[MAX_FRIEND_CLIENTS]; 1990 IP_Port ip_list[MAX_FRIEND_CLIENTS];
1992 const int ip_num = friend_iplist(dht, ip_list, num); 1991 const int ip_num = friend_iplist(dht, ip_list, num);
@@ -2001,10 +2000,6 @@ int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8_t *pack
2001 * is *usually* good(tm) (bites us in the behind in this case though) */ 2000 * is *usually* good(tm) (bites us in the behind in this case though) */
2002 2001
2003 for (uint32_t i = 0; i < MAX_FRIEND_CLIENTS; ++i) { 2002 for (uint32_t i = 0; i < MAX_FRIEND_CLIENTS; ++i) {
2004 if (friend_sent[i]) {/* Send one packet per client.*/
2005 continue;
2006 }
2007
2008 const Client_data *const client = &dht_friend->client_list[i]; 2003 const Client_data *const client = &dht_friend->client_list[i];
2009 const IPPTsPng *const assocs[] = { &client->assoc4, &client->assoc6, nullptr }; 2004 const IPPTsPng *const assocs[] = { &client->assoc4, &client->assoc6, nullptr };
2010 2005
@@ -2017,7 +2012,7 @@ int route_tofriend(const DHT *dht, const uint8_t *friend_id, const uint8_t *pack
2017 2012
2018 if ((unsigned int)retval == length) { 2013 if ((unsigned int)retval == length) {
2019 ++sent; 2014 ++sent;
2020 friend_sent[i] = 1; 2015 break; /* Send one packet per client.*/
2021 } 2016 }
2022 } 2017 }
2023 } 2018 }