Revision 672eb08e
src/PeerSampler/cloudcast.c | ||
---|---|---|
41 | 41 |
struct nodeID *dst; |
42 | 42 |
|
43 | 43 |
struct cloudcast_proto_context *proto_context; |
44 |
struct nodeID **r; |
|
44 | 45 |
}; |
45 | 46 |
|
46 | 47 |
|
... | ... | |
63 | 64 |
con->bootstrap_period = 2000000; |
64 | 65 |
con->period = 10000000; |
65 | 66 |
con->currtime = gettime(); |
66 |
|
|
67 |
con->r = NULL; |
|
67 | 68 |
con->cloud_contact_treshold = DEFAULT_CLOUD_CONTACT_TRESHOLD; |
68 | 69 |
|
69 | 70 |
return con; |
... | ... | |
298 | 299 |
|
299 | 300 |
static const struct nodeID **cloudcast_get_neighbourhood(struct peersampler_context *context, int *n) |
300 | 301 |
{ |
301 |
static struct nodeID **r; |
|
302 |
|
|
303 |
r = realloc(r, context->cache_size * sizeof(struct nodeID *)); |
|
304 |
if (r == NULL) { |
|
302 |
context->r = realloc(context->r, context->cache_size * sizeof(struct nodeID *)); |
|
303 |
if (context->r == NULL) { |
|
305 | 304 |
return NULL; |
306 | 305 |
} |
307 | 306 |
|
308 | 307 |
for (*n = 0; nodeid(context->local_cache, *n) && (*n < context->cache_size); (*n)++) { |
309 |
r[*n] = nodeid(context->local_cache, *n); |
|
308 |
context->r[*n] = nodeid(context->local_cache, *n);
|
|
310 | 309 |
//fprintf(stderr, "Checking table[%d]\n", *n); |
311 | 310 |
} |
312 | 311 |
if (context->flying_cache) { |
... | ... | |
315 | 314 |
for (i = 0; nodeid(context->flying_cache, i) && (*n < context->cache_size); (*n)++, i++) { |
316 | 315 |
dup = 0; |
317 | 316 |
for (j = 0; j<*n; j++){ |
318 |
if (nodeid_equal(r[j], nodeid(context->flying_cache, i))){ |
|
317 |
if (nodeid_equal(context->r[j], nodeid(context->flying_cache, i))){
|
|
319 | 318 |
dup = 1; |
320 | 319 |
continue; |
321 | 320 |
} |
322 | 321 |
} |
323 | 322 |
if (dup) (*n)--; |
324 |
else r[*n] = nodeid(context->flying_cache, i); |
|
323 |
else context->r[*n] = nodeid(context->flying_cache, i);
|
|
325 | 324 |
} |
326 | 325 |
} |
327 | 326 |
|
... | ... | |
329 | 328 |
int j,dup; |
330 | 329 |
dup = 0; |
331 | 330 |
for (j = 0; j<*n; j++){ |
332 |
if (nodeid_equal(r[j], context->dst)){ |
|
331 |
if (nodeid_equal(context->r[j], context->dst)){
|
|
333 | 332 |
dup = 1; |
334 | 333 |
continue; |
335 | 334 |
} |
336 | 335 |
} |
337 | 336 |
if (!dup){ |
338 |
r[*n] = context->dst; |
|
337 |
context->r[*n] = context->dst;
|
|
339 | 338 |
(*n)++; |
340 | 339 |
} |
341 | 340 |
} |
342 | 341 |
|
343 |
return (const struct nodeID **)r; |
|
342 |
return (const struct nodeID **)context->r;
|
|
344 | 343 |
} |
345 | 344 |
|
346 | 345 |
static const void *cloudcast_get_metadata(struct peersampler_context *context, int *metadata_size) |
Also available in: Unified diff