Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #369 from cole-miller/id
Browse files Browse the repository at this point in the history
lifecycle: Trace request ID if set
  • Loading branch information
Mathieu Borderé authored Jan 17, 2023
2 parents cf2625b + 00ee0d6 commit 07b0209
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/lifecycle.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
#include "lifecycle.h"
#include "queue.h"
#include "tracing.h"

#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

#define tracef(...) Tracef(r->tracer, __VA_ARGS__)

static bool reqIdIsSet(const struct request *req)
{
return req->req_id[15] == (uint8_t)-1;
}

static uint64_t extractReqId(const struct request *req)
{
uint64_t id;
memcpy(&id, &req->req_id, sizeof(id));
return id;
}

void lifecycleRequestStart(struct raft *r, struct request *req)
{
if (reqIdIsSet(req)) {
tracef("request start id:%" PRIu64, extractReqId(req));
}
QUEUE_PUSH(&r->leader_state.requests, &req->queue);
}

void lifecycleRequestEnd(struct raft *r, struct request *req)
{
(void)r;
if (reqIdIsSet(req)) {
tracef("request end id:%" PRIu64, extractReqId(req));
}
QUEUE_REMOVE(&req->queue);
}

0 comments on commit 07b0209

Please sign in to comment.