Revision 661d190d

View differences:

som/TopologyManager/ncast.c
84 84

  
85 85
int topParseData(const uint8_t *buff, int len)
86 86
{
87
  int dummy;
88

  
87 89
  if (len) {
88 90
    const struct topo_header *h = (const struct topo_header *)buff;
89 91
    struct peer_cache *new, *remote_cache;
......
100 102
      topo_reply(buff + sizeof(struct topo_header), len - sizeof(struct topo_header), local_cache);
101 103
    }
102 104
    remote_cache = entries_undump(buff + sizeof(struct topo_header), len - sizeof(struct topo_header));
103
    new = merge_caches(local_cache, remote_cache, cache_size);
105
    new = merge_caches(local_cache, remote_cache, cache_size, &dummy);
104 106
    cache_free(remote_cache);
105 107
    if (new != NULL) {
106 108
      cache_free(local_cache);
som/TopologyManager/topocache.c
289 289
  return res;
290 290
}
291 291

  
292
struct peer_cache *merge_caches_ranked(struct peer_cache *c1, struct peer_cache *c2, int newsize, ranking_function rank, struct peer_cache *me)
292
struct peer_cache *merge_caches_ranked(struct peer_cache *c1, struct peer_cache *c2, int newsize, int *source, ranking_function rank, struct peer_cache *me)
293 293
{
294 294
  int n1, n2;
295 295
  struct peer_cache *new_cache;
......
301 301
  }
302 302

  
303 303
  meta = new_cache->metadata;
304
  *source = 0;
304 305
  for (n1 = 0, n2 = 0; new_cache->current_size < new_cache->cache_size;) {
305 306
    if ((n1 == c1->current_size) && (n2 == c2->current_size)) {
306 307
      return new_cache;
......
313 314
        }
314 315
        new_cache->entries[new_cache->current_size++] = c2->entries[n2];
315 316
        c2->entries[n2].id = NULL;
317
        *source |= 0x02;
316 318
      }
317 319
      n2++;
318 320
    } else if (n2 == c2->current_size) {
......
323 325
        }
324 326
        new_cache->entries[new_cache->current_size++] = c1->entries[n1];
325 327
        c1->entries[n1].id = NULL;
328
        *source |= 0x01;
326 329
      }
327 330
      n1++;
328 331
    } else {
......
344 347
          }
345 348
          new_cache->entries[new_cache->current_size++] = c1->entries[n1];
346 349
          c1->entries[n1].id = NULL;
350
          *source |= 0x01;
347 351
        }
348 352
        n1++;
349 353
      } else {
......
354 358
          }
355 359
          new_cache->entries[new_cache->current_size++] = c2->entries[n2];
356 360
          c2->entries[n2].id = NULL;
361
          *source |= 0x02;
357 362
        }
358 363
        n2++;
359 364
      }
......
363 368
  return new_cache;
364 369
}
365 370

  
366
struct peer_cache *merge_caches(struct peer_cache *c1, struct peer_cache *c2, int newsize)
371
struct peer_cache *merge_caches(struct peer_cache *c1, struct peer_cache *c2, int newsize, int *source)
367 372
{
368
  return merge_caches_ranked(c1, c2, newsize, NULL, NULL);
373
  return merge_caches_ranked(c1, c2, newsize, source, NULL, NULL);
369 374
}
som/TopologyManager/topocache.h
16 16
struct peer_cache *entries_undump(const uint8_t *buff, int size);
17 17
int cache_header_dump(uint8_t *b, const struct peer_cache *c);
18 18
int entry_dump(uint8_t *b, struct peer_cache *e, int i);
19
struct peer_cache *merge_caches_ranked(struct peer_cache *c1, struct peer_cache *c2, int newsize, ranking_function rank, struct peer_cache *me);
20
struct peer_cache *merge_caches(struct peer_cache *c1, struct peer_cache *c2, int newsize);
19
struct peer_cache *merge_caches_ranked(struct peer_cache *c1, struct peer_cache *c2, int newsize, int *source, ranking_function rank, struct peer_cache *me);
20
struct peer_cache *merge_caches(struct peer_cache *c1, struct peer_cache *c2, int newsize, int *source);
21 21
void cache_update(struct peer_cache *c);
22 22
int empty(struct peer_cache *c);
23 23
void cache_free(struct peer_cache *c);

Also available in: Unified diff