Revision 5820d286

View differences:

src/psinstance.c
117 117
		if (res == 0)
118 118
		{
119 119
			ps->measure = measures_create(nodeid_static_str(ps->my_sock));
120
			ps->topology = topology_create(ps, "");
120
			ps->topology = topology_create(ps, config);
121 121
			streaming_timers_init(&(ps->timers), ps->chunk_offer_interval);
122 122
			ps->chunk_out = NULL;  // To be used as a flag if current role is source or peer role
123 123
			if (srv_port)
src/topology.c
30 30
#include <peersampler.h>
31 31
#include <peer.h>
32 32
#include <grapes_msg_types.h>
33
#include<grapes_config.h>
33 34
//
34 35
#include "compatibility/timer.h"
35 36
//
......
105 106

  
106 107
int topology_init(struct topology * t, const struct psinstance * ps, const char *config)
107 108
{
109
	struct tag * tags;
110
	int peer_timeout;
111

  
112
	tags = grapes_config_parse(config);
113

  
108 114
	bind_msg_type(MSG_TYPE_NEIGHBOURHOOD);
109 115
	bind_msg_type(MSG_TYPE_TOPOLOGY);
110
	t->tout_bmap.tv_sec = 20;
116

  
117
	grapes_config_value_int_default(tags, "peer_timeout", &peer_timeout, 10);
118
	t->tout_bmap.tv_sec = peer_timeout;
111 119
	t->tout_bmap.tv_usec = 0;
112 120
	t->ps = ps;
113 121

  
......
128 136
	update_metadata(t);
129 137
	t->tc = psample_init(psinstance_nodeid(ps), &(t->my_metadata), sizeof(struct metadata), config);
130 138
	
131
  //fprintf(stderr,"[DEBUG] done with topology init\n");
139
	free(tags);
132 140
	return t->tc && t->neighbourhood && t->swarm_bucket ? 1 : 0;
133 141
}
134 142

  
......
295 303
    if ( (!timerisset(&peers[i]->bmap_timestamp) && timercmp(&peers[i]->creation_timestamp, &told, <) ) ||
296 304
         ( timerisset(&peers[i]->bmap_timestamp) && timercmp(&peers[i]->bmap_timestamp, &told, <)     )   ) {
297 305
      dprintf("Topo: dropping inactive %s (peersset_size: %d)\n", nodeid_static_str(peers[i]->id), peerset_size(t->neighbourhood));
298
      if (peerset_size(t->neighbourhood) > 1) {	// avoid dropping our last link to the world
306
//      if (peerset_size(t->neighbourhood) > 1) {	// avoid dropping our last link to the world
299 307
	      topology_blacklist_add(t, peers[i]->id);
300
	      neighbourhood_remove_peer(t, peers[i]->id);
301
      }
308
	      topology_remove_peer(t, peers[i]->id);
309
//      }
302 310
    }
303 311
  }
304 312
	

Also available in: Unified diff