Revision cc8a901b

View differences:

src/PeerSampler/ncast.c
20 20
#include "config.h"
21 21
#include "grapes_msg_types.h"
22 22

  
23
#define BOOTSTRAP_CYCLES 5
24 23
#define DEFAULT_CACHE_SIZE 10
25 24
#define DEFAULT_MAX_TIMESTAMP 5
25
#define DEFAULT_BOOTSTRAP_CYCLES 5
26
#define DEFAULT_BOOTSTRAP_PERIOD 2*1000*1000
27
#define DEFAULT_PERIOD 10*1000*1000
26 28

  
27 29
struct peersampler_context{
28 30
  uint64_t currtime;
......
30 32
  struct peer_cache *local_cache;
31 33
  bool bootstrap;
32 34
  int bootstrap_period;
35
  int bootstrap_cycles;
33 36
  int period;
34 37
  int counter;
35 38
  struct ncast_proto_context *tc;
......
52 55

  
53 56
  //Initialize context with default values
54 57
  con->bootstrap = true;
55
  con->bootstrap_period = 2000000;
56
  con->period = 10000000;
57 58
  con->currtime = gettime();
58 59
  con->r = NULL;
59 60

  
......
93 94
  if (!res) {
94 95
    max_timestamp = DEFAULT_MAX_TIMESTAMP;
95 96
  }
97
  res = config_value_int(cfg_tags, "period", &context->period);
98
  if (!res) {
99
    context->period = DEFAULT_PERIOD;
100
  }
101
  res = config_value_int(cfg_tags, "bootstrap_period", &context->bootstrap_period);
102
  if (!res) {
103
    context->bootstrap_period = DEFAULT_BOOTSTRAP_PERIOD;
104
  }
105
  res = config_value_int(cfg_tags, "bootstrap_cycles", &context->bootstrap_cycles);
106
  if (!res) {
107
    context->bootstrap_cycles = DEFAULT_BOOTSTRAP_CYCLES;
108
  }
96 109
  free(cfg_tags);
97 110
  
98 111
  context->local_cache = cache_init(context->cache_size, metadata_size, max_timestamp);
......
143 156
    }
144 157

  
145 158
    context->counter++;
146
    if (context->counter == BOOTSTRAP_CYCLES) context->bootstrap = false;
159
    if (context->counter == context->bootstrap_cycles) context->bootstrap = false;
147 160

  
148 161
    remote_cache = entries_undump(buff + sizeof(struct topo_header), len - sizeof(struct topo_header));
149 162
    if (h->type == NCAST_QUERY) {

Also available in: Unified diff