summaryrefslogtreecommitdiff
path: root/src/proto.c
diff options
context:
space:
mode:
authorJesper Jensen <DelusionalLogic@users.noreply.github.com>2021-10-27 20:29:41 +0200
committerGitHub <noreply@github.com>2021-10-27 20:29:41 +0200
commit4527a87385c56cb2a5cf0269d4638b604a1f039b (patch)
tree031e8a09ec26229b31f58e2189d0023898881d20 /src/proto.c
parentef39868b6bffa3030c7cbc083df1301849fba0f7 (diff)
parent42a627aab5e47c3f3e05460322b9c1c3f2c69214 (diff)
Merge pull request #1 from DelusionalLogic/mainflush
Mainflush
Diffstat (limited to 'src/proto.c')
-rw-r--r--src/proto.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/proto.c b/src/proto.c
index 8f4f737..b518f79 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -180,7 +180,7 @@ PROCESS_TIMEOUT(getclient_timeout) {
size_t reqId = (typeof(dht->requestdata[0])*)((void*)cont - offsetof(typeof(dht->requestdata[0]), cont)) - dht->requestdata;
if(cont->ping.attempt >= 2) {
- dbg("Timing out request %d after %d attempts", reqId, cont->ping.attempt);
+ dbg("Timing out request %ld after %d attempts", reqId, cont->ping.attempt);
if(cont->ping.is_new)
return 0;
@@ -190,7 +190,7 @@ PROCESS_TIMEOUT(getclient_timeout) {
return 0;
}
- dbg("Retrying request %d", reqId);
+ dbg("Retrying request %ld", reqId);
if(*msgbuff->messages >= msgbuff->messages_end)
return PROTO_ENOREQ;
@@ -320,6 +320,7 @@ PROCESS_REPONSE(getclient_response) {
}
} else {
struct entry* entry = routing_get(&id);
+ assert(entry != NULL);
entry->expire = now + PROTO_UNCTM;
}
@@ -356,7 +357,6 @@ enum commandType {
};
void proto_begin(struct dht* dht, time_t now, struct message** output, const struct message* const output_end) {
- routing_flush();
struct msgbuff msgbuff = {
output,
output_end,
@@ -367,7 +367,6 @@ void proto_begin(struct dht* dht, time_t now, struct message** output, const str
dht->reqalloc[i] = false;
}
- routing_init(&dht->self);
dbgl_id(&dht->self);
dht->sfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
@@ -459,7 +458,7 @@ int handle_packet(struct dht* dht, time_t now, enum commandType type, char* tran
assert(*msgbuff->messages < msgbuff->messages_end);
struct message* message = *msgbuff->messages;
- char* end = message->payload+128;
+ char* end = message->payload+sizeof(message->payload);
char* cursor = message->payload;
int rc = snprintf(cursor, end-cursor , "d1:t%ld:", transaction_len);
@@ -646,7 +645,7 @@ int proto_run(struct dht* dht, char* buff, size_t recv_len, struct sockaddr_in*
}
}
- dbg("%d/%d requests pending", allocated, MAX_INFLIGHT);
+ dbg("%ld/%ld requests pending", allocated, MAX_INFLIGHT);
}
{
int filled;