diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 4 | ||||
| -rw-r--r-- | src/proto.c | 2 | ||||
| -rw-r--r-- | src/routing.c | 10 | ||||
| -rw-r--r-- | src/routing.h | 2 |
4 files changed, 15 insertions, 3 deletions
@@ -4,6 +4,7 @@ #include "metrics.h" #include <time.h> +#include <sys/time.h> #include <assert.h> #include <errno.h> #include <signal.h> @@ -158,13 +159,14 @@ int main(int argc, char** argv) { struct dht dht = {0}; { + routing_init(NULL); int rc = read_config(); if(rc == CONF_ENO) { for(uint16_t i = 0; i < sizeof(myID.inner_b); i++) { myID.inner_b[i] = rand(); } /* myID = (struct nodeid){.inner={0xebe9bbf1, 0x3cdba6b3, 0x993e0c87, 0x900d5e25, 0x00000000}}; */ - routing_flush(); + routing_init(&myID); allocate_hashtable(); } diff --git a/src/proto.c b/src/proto.c index b956356..2247162 100644 --- a/src/proto.c +++ b/src/proto.c @@ -518,6 +518,8 @@ void proto_begin(struct dht* dht, time_t now, struct message** output, const str send_ping(dht, NULL, now, true, cur->ai_addr, cur->ai_addrlen, &msgbuff); } + dht->tokens.head = 0; + freeaddrinfo(res); } diff --git a/src/routing.c b/src/routing.c index dc8c2bf..eca84f9 100644 --- a/src/routing.c +++ b/src/routing.c @@ -42,9 +42,17 @@ struct table { struct table* pTable; +struct nodeid myID; +struct entry *table; +int table_size = RT_SIZE; + void routing_init(struct nodeid* myid) { pTable = malloc(sizeof(struct table)); - pTable->myID = *myid; + if(myid != NULL) pTable->myID = *myid; + + table = pTable->table; + myID = pTable->myID; + routing_flush(); } diff --git a/src/routing.h b/src/routing.h index a435a94..63e7fa2 100644 --- a/src/routing.h +++ b/src/routing.h @@ -33,7 +33,7 @@ struct entry { }; extern struct nodeid myID; -extern struct entry table[]; +extern struct entry *table; extern int table_size; void routing_init(struct nodeid* myid); |
