diff --git a/overlay.c b/overlay.c index 145caf21..65239d18 100644 --- a/overlay.c +++ b/overlay.c @@ -69,6 +69,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "serval.h" +#include "rhizome.h" #include "strbuf.h" int overlayMode=0; @@ -83,6 +84,10 @@ int overlayServerMode() send periodic traffic. This means we need to */ INFO("Running in overlay mode."); + /* Make sure rhizome configured settings are known. */ + if (rhizome_fetch_interval_ms < 1) + rhizome_configure(); + /* Get keyring available for use. Required for MDP, and very soon as a complete replacement for the HLR for DNA lookups, even in non-overlay mode. */ @@ -137,7 +142,7 @@ schedule(&_sched_##X); /* Pick next rhizome files to grab every few seconds from the priority list continuously being built from observed bundle announcements */ - SCHEDULE(rhizome_enqueue_suggestions, 3000); + SCHEDULE(rhizome_enqueue_suggestions, rhizome_fetch_interval_ms); /* Periodically check for new interfaces */ SCHEDULE(overlay_interface_discover, 1); diff --git a/rhizome.c b/rhizome.c index c1b6bd88..ec6acf10 100644 --- a/rhizome.c +++ b/rhizome.c @@ -21,6 +21,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "rhizome.h" #include +static int rhizome_enabled_flag = -1; // unknown +int rhizome_fetch_interval_ms = -1; + +/* Configure rhizome. + @author Andrew Bettison + */ +int rhizome_configure() +{ + rhizome_enabled_flag = confValueGetBoolean("rhizome.enable", 1); + rhizome_fetch_interval_ms = (int) confValueGetInt64Range("rhizome.fetch_interval_ms", 3000, 1, 3600000); + return 0; +} + +int rhizome_enabled() +{ + if (rhizome_enabled_flag < 0) + rhizome_configure(); + return rhizome_enabled_flag; +} + /* Import a bundle from the inbox folder. The bundle is contained a pair of files, one containing the manifest and the optional other containing the payload. diff --git a/rhizome.h b/rhizome.h index 1aba6e4b..4d18a80f 100644 --- a/rhizome.h +++ b/rhizome.h @@ -127,6 +127,9 @@ typedef struct rhizome_manifest { #define RHIZOME_SERVICE_MESHMS "MeshMS1" extern long long rhizome_space; +extern int rhizome_fetch_interval_ms; + +int rhizome_configure(); int rhizome_set_datastore_path(const char *path); diff --git a/rhizome_database.c b/rhizome_database.c index 4e170e66..6d09418c 100644 --- a/rhizome_database.c +++ b/rhizome_database.c @@ -24,15 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. long long rhizome_space=0; static const char *rhizome_thisdatastore_path = NULL; -static int rhizome_enabled_flag = -1; // unknown -#define SQLITE_CODE_OK(code) (code==SQLITE_OK || code==SQLITE_DONE) -int rhizome_enabled() -{ - if (rhizome_enabled_flag < 0) - rhizome_enabled_flag = confValueGetBoolean("rhizome.enable", 1); - return rhizome_enabled_flag; -} +#define SQLITE_CODE_OK(code) (code==SQLITE_OK || code==SQLITE_DONE) const char *rhizome_datastore_path() { diff --git a/rhizome_fetch.c b/rhizome_fetch.c index 22012db5..063fb8eb 100644 --- a/rhizome_fetch.c +++ b/rhizome_fetch.c @@ -529,7 +529,7 @@ void rhizome_enqueue_suggestions(struct sched_ent *alarm) bcopy(&candidates[i],&candidates[0],bytes); candidate_count-=i; } - alarm->alarm = overlay_gettime_ms() + 3000; + alarm->alarm = overlay_gettime_ms() + rhizome_fetch_interval_ms; schedule(alarm); return; } @@ -721,7 +721,7 @@ int rhizome_queue_manifest_import(rhizome_manifest *m, struct sockaddr_in *peeri } else { - if (1||debug&DEBUG_RHIZOMESYNC) + if (debug&DEBUG_RHIZOMESYNC) DEBUGF("We already have the file for this manifest; importing from manifest alone."); if (create_rhizome_import_dir() == -1) return -1; diff --git a/tests/rhizomeprotocol b/tests/rhizomeprotocol index f9a07425..a2f1e711 100755 --- a/tests/rhizomeprotocol +++ b/tests/rhizomeprotocol @@ -44,6 +44,7 @@ configure_servald_server() { executeOk_servald config set debug.rhizomesync on executeOk_servald config set mdp.wifi.tick_ms 100 executeOk_servald config set mdp.selfannounce.ticks_per_full_address 1 + executeOk_servald config set rhizome.fetch_interval_ms 100 } doc_FileTransferNew="Initial list is empty"