summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesper Jensen <jesper@jnsn.dev>2025-04-12 12:25:02 +0200
committerJesper Jensen <jesper@jnsn.dev>2025-04-12 15:22:20 +0200
commitf15040b30fd7aea7141aa12b369036a82a69ff72 (patch)
tree7c8f05889cc5092013e5fe10f770750a98c7b680
parent6fdabfdf0865f0516eaac469f0febd25daae01ae (diff)
Add a docker container
-rw-r--r--.gitmodules3
-rw-r--r--Makefile1
-rw-r--r--src/main.c4
-rw-r--r--src/proto.c2
-rw-r--r--src/routing.c10
-rw-r--r--src/routing.h2
m---------thirdparty/prometheus-client-c0
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
diff --git a/Makefile b/Makefile
index 1c04ac4..713ea21 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/src/main.c b/src/main.c
index a51fcfc..ea1b9de 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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