summaryrefslogtreecommitdiffstats
path: root/src/serverconfig.h
diff options
context:
space:
mode:
authorSimon Rettberg2020-03-04 17:49:50 +0100
committerSimon Rettberg2020-03-04 17:49:50 +0100
commit930b65f26cb39687a113641f56711a2d58f886ca (patch)
treee0a0c5e73ea9820a4d64641209bde320359c37a2 /src/serverconfig.h
parent[SERVER] Likewise, get rid of same loops in client handler (diff)
downloaddnbd3-930b65f26cb39687a113641f56711a2d58f886ca.tar.gz
dnbd3-930b65f26cb39687a113641f56711a2d58f886ca.tar.xz
dnbd3-930b65f26cb39687a113641f56711a2d58f886ca.zip
[SERVER] Add timer task for saving cache maps
Cache maps will now be saved periodically, but only if either they have a "dirty" bit set, which happens if any bits in the map get cleared again (due to corruption), or if new data has been replicated from an uplink server. This either means at least one byte received and 5 minutes have passed, or at least 500MB have been downloaded. The timer currently runs every 20 seconds.
Diffstat (limited to 'src/serverconfig.h')
-rw-r--r--src/serverconfig.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/serverconfig.h b/src/serverconfig.h
index 239f0a2..5c7301d 100644
--- a/src/serverconfig.h
+++ b/src/serverconfig.h
@@ -17,7 +17,10 @@
#define SERVER_UPLINK_QUEUELEN_THRES 900 // Threshold where we start dropping incoming clients
#define SERVER_MAX_PENDING_ALT_CHECKS 500 // Length of queue for pending alt checks requested by uplinks
-#define SERVER_CACHE_MAP_SAVE_INTERVAL 90
+// Wait a maximum of 5 minutes before saving cache map (if data was received at all)
+#define CACHE_MAP_MAX_SAVE_DELAY 300
+// If more than 500MB have been received from uplink without saving cache map, do so
+#define CACHE_MAP_MAX_UNSAVED_BYTES ((uint64_t)500 * 1000 * 1000)
// Time in ms to wait for a read/write call to complete on an uplink connection
#define SOCKET_TIMEOUT_UPLINK 5000