Skip to content

Commit

Permalink
Added means of measuring memory consumption
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdelisle committed Feb 12, 2012
1 parent 29e9f96 commit 8668fc1
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions cjdroute.c
Expand Up @@ -606,19 +606,33 @@ static void adminPing(Dict* input, void* vadmin, String* txid)
uint8_t buffer[256];
struct Allocator* alloc = BufferAllocator_new(buffer, 256);

String pong = { .len = 4, .bytes = "pong" };
String* pong = BSTR("pong");
Dict* d = Dict_new(alloc);
Dict_putString(d, CJDHTConstants_QUERY, &pong, alloc);
Dict_putString(d, CJDHTConstants_QUERY, pong, alloc);

Admin_sendMessage(d, txid, (struct Admin*) vadmin);
}

static void adminMemory(Dict* input, void* vcontext, String* txid)
{
struct Context* context = (struct Context*) vcontext;
uint8_t buffer[256];
struct Allocator* alloc = BufferAllocator_new(buffer, 256);

String* bytes = BSTR("bytes");
Dict* d = Dict_new(alloc);
Dict_putInt(d, bytes, MallocAllocator_bytesAllocated(context->allocator), alloc);

Admin_sendMessage(d, txid, context->admin);
}

static void admin(Dict* adminConf, char* user, struct Context* context)
{
context->admin =
Admin_new(adminConf, user, context->base, context->eHandler, context->allocator);

Admin_registerFunction("ping", adminPing, context->admin, false, context->admin);
Admin_registerFunction("memory", adminMemory, context, false, context->admin);
}

static void pidfile(Dict* config)
Expand Down

0 comments on commit 8668fc1

Please sign in to comment.