Revision 9589827a som/TopologyManager/tman.c

View differences:

som/TopologyManager/tman.c
170 170

  
171 171
	if (len) {
172 172
		const struct topo_header *h = (const struct topo_header *)buff;
173
		struct peer_cache *remote_cache; int idx;
173
		struct peer_cache *remote_cache;
174 174

  
175 175
	    if (h->protocol != MSG_TYPE_TMAN) {
176 176
	      fprintf(stderr, "TMAN: Wrong protocol!\n");
......
199 199
				// TODO: put sender in tabu list (check list size, etc.), if any...
200 200
			}
201 201
		}
202
		idx = cache_add_ranked(local_cache, nodeid(remote_cache,0), mdata, msize, rankFunct, mymeta);
202
		cache_add_ranked(local_cache, nodeid(remote_cache,0), mdata, msize, rankFunct, mymeta);
203 203
//		fprintf(stderr, "\tidx = %d\n",idx);
204 204
		new = merge_caches_ranked(local_cache, remote_cache, cache_size, &source, rankFunct, mymeta);
205 205

  
......
212 212
		if (new!=NULL) {
213 213
		  cache_free(local_cache);
214 214
		  local_cache = new;
215
                }
216
                if (source) {
217
		  if (idx>=0 || source!=1) {
215
		  if (source > 1) {
218 216
                  	active = IDLE_TIME;
219 217
                  }
220 218
                  else {
......
233 231
	cache_update(local_cache);
234 232
	if (active == 0) {
235 233
		struct peer_cache *ncache;
236
		int j, res = 0;
234
		int j;
237 235

  
238 236
		ncache = cache_init(size,metadata_size);
239
		for (j=0;j<size && res!=-3;j++)
240
			res = cache_add_ranked(ncache, peers[j],(const uint8_t *)metadata + j * metadata_size, metadata_size, rankFunct, mymeta);
237
		for (j=0;j<size;j++)
238
			cache_add_ranked(ncache, peers[j],(const uint8_t *)metadata + j * metadata_size, metadata_size, rankFunct, mymeta);
241 239
		if (nodeid(ncache, 0)) {
242 240
			new = merge_caches_ranked(local_cache, ncache, cache_size, &source, rankFunct, mymeta);
243 241
                        if (new) {
244 242
				cache_free(local_cache);
245 243
				local_cache = new;
246
			}
247
			if (source!=1) {
248
				active = TMAN_IDLE_TIME;
244
			if (source > 1) {
245
				active = IDLE_TIME;
249 246
			}
250 247
			do_resize = 0;
251 248
		}
249
		}
252 250
		cache_free(ncache);
253 251
	}
254 252
		

Also available in: Unified diff