chiark / gitweb /
site: Change default number of mobile peers
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 3 Oct 2014 17:32:25 +0000 (18:32 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 5 Oct 2014 20:06:29 +0000 (21:06 +0100)
As the comment has it:

   - The default number of addrs to keep is 3, or 4 if we have a
     configured name or address.  That's space for two configured
     addresses (one IPv6 and one IPv4), plus two received addresses.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
README
site.c

diff --git a/README b/README
index 962755e2ae9775c88344e6df0fb17ebcf2866eee..f5b3b2b42a68b36bbca933d5d6f2d5a7cd28528c 100644 (file)
--- a/README
+++ b/README
@@ -318,10 +318,11 @@ site: dict argument
     address may suddenly change couldn't communicate reliably because
     their contact addresses might both change at once. [false]
   mobile-peers-max (integer): Maximum number of peer port/addr pairs we
-    remember and send to.  Must be at least 1 and no more than 5.  [3]
+    remember and send to.  Must be at least 1 and no more than 5.
+    [4 if an address is configured, otherwise 3]
   static-peers-max (integer): Maximum number of peer port/addr pairs
     we can try for a static site.  Must be at least 1 and no more
-    than 5.  [3]
+    than 5.  [4 or 3, as above]
   mobile-peer-expiry (integer): For "mobile" peers only, the length
     of time (in seconds) for which we will keep sending to multiple
     address/ports from which we have not seen incoming traffic. [120]
diff --git a/site.c b/site.c
index ecb45bf150b58bf10b15aa9ef08b59eb3e3b90bf..204ddf5dce812bb66e1e1022a3c8580727a538fc 100644 (file)
--- a/site.c
+++ b/site.c
@@ -40,7 +40,6 @@
 #define DEFAULT_MOBILE_WAIT_TIME                (10*1000) /* [ms] */
 
 #define DEFAULT_MOBILE_PEER_EXPIRY            (2*60)      /* [s] */
-#define DEFAULT_PEERS_MAX 3 /* send at most this many copies (default) */
 
 /* Each site can be in one of several possible states. */
 
@@ -1968,7 +1967,7 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context,
     const char *peerskey= st->peer_mobile
        ? "mobile-peers-max" : "static-peers-max";
     st->transport_peers_max= dict_read_number(
-       dict,peerskey,False,"site",loc,DEFAULT_PEERS_MAX);
+       dict,peerskey,False,"site",loc, st->address ? 4 : 3);
     if (st->transport_peers_max<1 ||
        st->transport_peers_max>MAX_PEER_ADDRS) {
        cfgfatal(loc,"site", "%s must be in range 1.."