Revision 018c744a
loop.c | ||
---|---|---|
9 | 9 |
#include <topmanager.h> |
10 | 10 |
#include <msg_types.h> |
11 | 11 |
#include <peerset.h> |
12 |
#include <peer.h> |
|
12 | 13 |
|
13 | 14 |
#include "chunk_signaling.h" |
14 | 15 |
#include "streaming.h" |
... | ... | |
17 | 18 |
#define BUFFSIZE 64 * 1024 |
18 | 19 |
static struct timeval period = {0, 500000}; |
19 | 20 |
static struct timeval tnext; |
21 |
static struct timeval tout_bmap = {3, 0}; |
|
20 | 22 |
|
21 | 23 |
|
22 | 24 |
void tout_init(struct timeval *tv) |
... | ... | |
37 | 39 |
// currently it just makes the peerset grow |
38 | 40 |
void update_peers(struct peerset *pset, const uint8_t *buff, int len) |
39 | 41 |
{ |
40 |
int n_ids; |
|
42 |
int n_ids, i;
|
|
41 | 43 |
const struct nodeID **ids; |
44 |
struct peer *peers; |
|
45 |
struct timeval tnow, told; |
|
46 |
|
|
47 |
|
|
42 | 48 |
topParseData(buff, len); |
43 | 49 |
ids = topGetNeighbourhood(&n_ids); |
44 | 50 |
peerset_add_peers(pset,ids,n_ids); |
51 |
|
|
52 |
gettimeofday(&tnow, NULL); |
|
53 |
timersub(&tnow, &tout_bmap, &told); |
|
54 |
peers = peerset_get_peers(pset); |
|
55 |
for (i = 0; i < peerset_size(pset); i++) { |
|
56 |
if (timerisset(&peers[i].bmap_timestamp) && timercmp(&peers[i].bmap_timestamp, &told, <)) { |
|
57 |
peerset_remove_peer(pset, peers[i--].id); |
|
58 |
} |
|
59 |
} |
|
45 | 60 |
} |
46 | 61 |
|
47 | 62 |
|
Also available in: Unified diff