From 78e079c46c6ca0481ec77705db9ae4dec117be4e Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 25 Oct 2017 17:01:18 +0200 Subject: peer: store total number of peers instead of iterating This is faster, since it means adding a new peer is O(1) instead of O(n). It's also safe to do because we're holding the device_update_lock on both the ++ and the --. --- src/device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/device.h') diff --git a/src/device.h b/src/device.h index 4932477..a74f58b 100644 --- a/src/device.h +++ b/src/device.h @@ -49,7 +49,7 @@ struct wireguard_device { struct routing_table peer_routing_table; struct mutex device_update_lock, socket_update_lock; struct list_head device_list, peer_list; - unsigned int device_update_gen; + unsigned int num_peers, device_update_gen; u32 fwmark; u16 incoming_port; }; -- cgit v1.2.3-59-g8ed1b