diff options
| -rw-r--r-- | .gitmodules | 3 | ||||
| -rw-r--r-- | Makefile | 1 | ||||
| -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 | ||||
| m--------- | thirdparty/prometheus-client-c | 0 |
7 files changed, 18 insertions, 4 deletions
diff --git a/.gitmodules b/.gitmodules index 24dbdbe..25bb6ac 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "thirdparty/Unity"] path = thirdparty/Unity url = https://github.com/ThrowTheSwitch/Unity.git +[submodule "thirdparty/prometheus-client-c"] + path = thirdparty/prometheus-client-c + url = https://github.com/digitalocean/prometheus-client-c.git @@ -83,6 +83,5 @@ $(OBJDIR)/thirdparty/Unity/%.o: thirdparty/Unity/%.c @mkdir -p $(dir $@) $(CC) $(CFLAGS) $(TEST_LIB_CFLAGS) $(TEST_LIB_INCS) $(INCS) -MMD -o $@ -c $< - .DEFAULT_GOAL := all all: test dht @@ -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); diff --git a/thirdparty/prometheus-client-c b/thirdparty/prometheus-client-c new file mode 160000 +Subproject c57034d196582d99267d027abb52a05a55dc07f |
