Revision 50fea9dc som/TopologyManager/tman.c

View differences:

som/TopologyManager/tman.c
19 19
#include "msg_types.h"
20 20
#include "tman.h"
21 21

  
22
#define TMAN_INIT_PEERS 20 // max # of neighbors in local cache (should be >= than the next)
23
#define TMAN_MAX_PREFERRED_PEERS 20 // # of peers to choose a receiver among (should be <= than the previous)
24
#define TMAN_MAX_GOSSIPING_PEERS 20 // # size of the view to be sent to receiver peer (should be <= than the previous)
22
#define TMAN_INIT_PEERS 10 // max # of neighbors in local cache (should be >= than the next)
23
#define TMAN_MAX_PREFERRED_PEERS 10 // # of peers to choose a receiver among (should be <= than the previous)
24
#define TMAN_MAX_GOSSIPING_PEERS 10 // # size of the view to be sent to receiver peer (should be <= than the previous)
25 25
#define TMAN_IDLE_TIME 10 // # of iterations to wait before switching to inactive state
26
#define TMAN_STD_PERIOD 3000000
26
#define TMAN_STD_PERIOD 10000000
27 27
#define TMAN_INIT_PERIOD 1000000
28 28

  
29 29
static  int max_preferred_peers = TMAN_MAX_PREFERRED_PEERS;
......
88 88
    max_gossiping_peers = gossip_peers;
89 89
  }
90 90
  max_preferred_peers = TMAN_MAX_PREFERRED_PEERS;
91
  active = 0;
91
  active = -1;
92 92
  currtime = gettime();
93 93

  
94 94
  return 0;
......
234 234
	struct nodeID *chosen;
235 235

  
236 236
	cache_update(local_cache);
237
	if (active == 0) {
237

  
238
	if (active <= 0) {
238 239
		struct peer_cache *ncache;
239 240
		int j;
240 241

  
......
245 246
		if (nodeid(ncache, 0)) {
246 247
			restart_peer = nodeid_dup(nodeid(ncache, 0));
247 248
			mdata = get_metadata(ncache, &msize);
248
			new = rank_cache(local_cache, restart_peer, mdata);
249
			new = rank_cache(active<0?ncache:local_cache, restart_peer, mdata);
249 250
			if (new) {
250 251
				tman_query_peer(new, restart_peer);
251 252
				cache_free(new);
252 253
			}
253 254
		}
254
		cache_free(ncache);
255
		if (active < 0) {
256
			local_cache = ncache;
257
			active = 0;
258
		} else {
259
			cache_free(ncache);
260
		}
255 261
	}
256 262
	else {
257 263
	chosen = rand_peer(local_cache, (void **)&meta);		//MAX_PREFERRED_PEERS

Also available in: Unified diff