shithub: choc

Download patch

ref: 708d6e0a0250a974c9db0fdf006acfb18794e370
parent: 89b2315275de48ee66241e883b6e7d8695af3c75
author: Simon Howard <fraggle@soulsphere.org>
date: Sun Feb 10 08:11:39 EST 2019

net: Increase master server refresh period.

Now that some servers may be behind NAT gateways, it is important that
we send packets to the master server regularly so that it can forward
hole punch requests to us. With the previous value of a refresh every
20 minutes, some NAT gateways may discard the state. Change to 30
seconds (twice per minute) so that the connection is kept alive.

Rationale: Wikipedia article on UDP hole punching says:
> UDP state usually expires after short periods of time in the range
> of tens of seconds to a few minutes

Based on this, 30 seconds seems like a reasonable value.

--- a/src/net_server.c
+++ b/src/net_server.c
@@ -40,11 +40,9 @@
 #include "net_structrw.h"
 
 // How often to refresh our registration with the master server.
+#define MASTER_REFRESH_PERIOD 30  /* twice per minute */
 
-#define MASTER_REFRESH_PERIOD 20 * 60 /* 20 minutes */
-
 // How often to re-resolve the address of the master server?
-
 #define MASTER_RESOLVE_PERIOD 8 * 60 * 60 /* 8 hours */
 
 typedef enum