Add "rhizome.fetch_interval_ms" config option

This commit is contained in:
Andrew Bettison 2012-07-11 16:50:50 +09:30
parent 218e7883ce
commit ff2c98afb3
6 changed files with 33 additions and 11 deletions

View File

@ -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);

View File

@ -21,6 +21,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "rhizome.h"
#include <stdlib.h>
static int rhizome_enabled_flag = -1; // unknown
int rhizome_fetch_interval_ms = -1;
/* Configure rhizome.
@author Andrew Bettison <andrew@servalproject.com>
*/
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.

View File

@ -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);

View File

@ -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()
{

View File

@ -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;

View File

@ -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"