static void
_metisStreamConnection_DestroyOperations(MetisIoOperations **opsPtr)
{
    assertNotNull(opsPtr, "Parameter opsPtr must be non-null double pointer");
    assertNotNull(*opsPtr, "Parameter opsPtr must dereference to non-null pointer");

    MetisIoOperations *ops = *opsPtr;
    assertNotNull(metisIoOperations_GetClosure(ops), "ops->context must not be null");

    _MetisStreamState *stream = (_MetisStreamState *) metisIoOperations_GetClosure(ops);

    parcEventQueue_Destroy(&stream->bufferEventVector);

    metisAddressPair_Release(&stream->addressPair);

    if (!stream->isClosed) {
        stream->isClosed = true;
        metisMessenger_Send(metisForwarder_GetMessenger(stream->metis), metisMissive_Create(MetisMissiveType_ConnectionClosed, stream->id));
    }

    metisMessenger_Send(metisForwarder_GetMessenger(stream->metis), metisMissive_Create(MetisMissiveType_ConnectionDestroyed, stream->id));

    if (metisLogger_IsLoggable(stream->logger, MetisLoggerFacility_IO, PARCLogLevel_Info)) {
        metisLogger_Log(stream->logger, MetisLoggerFacility_IO, PARCLogLevel_Info, __func__,
                        "StreamConnection %p destroyed", (void *) stream);
    }

    metisLogger_Release(&stream->logger);
    parcMemory_Deallocate((void **) &stream);
    parcMemory_Deallocate((void **) &ops);

    *opsPtr = NULL;
}
Exemple #2
0
LONGBOW_TEST_CASE(Global, metisMessage_ReadFromBuffer)
{
    char message_str[] = "\x00Once upon a time, in a stack far away, a dangling pointer found its way to the top of the heap.";

    PARCEventBuffer *buff = parcEventBuffer_Create();
    parcEventBuffer_Append(buff, message_str, sizeof(message_str));

    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_ReadFromBuffer(1, 2, buff, sizeof(message_str), logger);
    metisLogger_Release(&logger);

    assertNotNull(message, "Got null from metisMessage_CreateFromBuffer");

    assertTrue(parcEventBuffer_GetLength(message->messageBytes) == sizeof(message_str),
               "Length of internal buffer wrong, expected %zu got %zu",
               sizeof(message_str),
               parcEventBuffer_GetLength(message->messageBytes));

    uint8_t *p = parcEventBuffer_Pullup(message->messageBytes, sizeof(message_str));
    assertTrue(memcmp(p, message_str, sizeof(message_str)) == 0, "Internal buffer contents does not match test");
    assertTrue(message->ingressConnectionId == 1, "IngressConnectionId wrong, expected %d got %u", 1, message->ingressConnectionId);
    assertTrue(message->receiveTime == 2, "receiveTime wrong, expected %u got %" PRIu64, 2, message->receiveTime);
    assertTrue(parcEventBuffer_GetLength(buff) == 0, "Origin buffer not drained, expected 0, got %zu", parcEventBuffer_GetLength(buff));

    metisMessage_Release(&message);
    parcEventBuffer_Destroy(&buff);
}
Exemple #3
0
LONGBOW_TEST_CASE(Global, metisMessage_IsPublicKeyVerified_False)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);

    MetisMessage *contentWithKey =
        metisMessage_CreateFromArray(metisTestDataV1_ContentObject_NameA_KeyId1_RsaSha256,
                                     sizeof(metisTestDataV1_ContentObject_NameA_KeyId1_RsaSha256), 1, 2, logger);

    MetisMessage *interestWithKeyIdRestriction =
        metisMessage_CreateFromArray(metisTestDataV1_Interest_NameAAndKeyId,
                                     sizeof(metisTestDataV1_Interest_NameAAndKeyId), 1, 2, logger);

    metisLogger_Release(&logger);

    assertFalse(metisMessage_IsKeyIdVerified(contentWithKey), "Expected key to not be verified.");

    // This is an interest. The keyId is actually a KeyId restriction, so will never be verified.
    assertFalse(metisMessage_IsKeyIdVerified(interestWithKeyIdRestriction), "Expected key to not be verified.");

    PARCBuffer *key = metisMessage_GetPublicKey(contentWithKey);

    assertNotNull(key, "Expected to retrieve the public key");

    metisMessage_Release(&contentWithKey);
    metisMessage_Release(&interestWithKeyIdRestriction);
}
Exemple #4
0
LONGBOW_TEST_CASE(Global, metisMessage_HasGetPublicKey)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);

    MetisMessage *contentWithKey =
        metisMessage_CreateFromArray(metisTestDataV1_ContentObject_NameA_KeyId1_RsaSha256,
                                     sizeof(metisTestDataV1_ContentObject_NameA_KeyId1_RsaSha256), 1, 2, logger);

    MetisMessage *interestWithKeyIdRestriction =
        metisMessage_CreateFromArray(metisTestDataV1_Interest_NameAAndKeyId,
                                     sizeof(metisTestDataV1_Interest_NameAAndKeyId), 1, 2, logger);

    metisLogger_Release(&logger);

    assertTrue(metisMessage_HasPublicKey(contentWithKey), "Expected to see a public key");
    assertFalse(metisMessage_HasPublicKey(interestWithKeyIdRestriction), "Expected to not see a public key");

    PARCBuffer *key = metisMessage_GetPublicKey(contentWithKey);

    assertNotNull(key, "Expected to retrieve the public key");

    metisMessage_Release(&contentWithKey);
    metisMessage_Release(&interestWithKeyIdRestriction);
}
Exemple #5
0
LONGBOW_TEST_CASE(Global, metisMessage_Copy)
{
    char message_str[] = "\x00Once upon a time, in a stack far away, a dangling pointer found its way to the top of the heap.";

    PARCEventBuffer *buff = parcEventBuffer_Create();
    parcEventBuffer_Append(buff, message_str, sizeof(message_str));

    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromBuffer(1, 2, buff, logger);
    metisLogger_Release(&logger);

    assertNotNull(message, "Got null from metisMessage_CreateFromBuffer");
    assertTrue(message->refcount == 1, "Incorrect refcount, expected %u got %u", 1, message->refcount);

    MetisMessage *copy = metisMessage_Acquire(message);
    assertTrue(message->refcount == 2, "Incorrect refcount, expected %u got %u", 2, message->refcount);

    metisMessage_Release(&message);
    assertTrue(copy->refcount == 1, "Incorrect refcount, expected %u got %u", 1, message->refcount);

    metisMessage_Release(&copy);

    assertTrue(parcMemory_Outstanding() == 0, "Memory balance should be zero after destroying last copy, got %u", parcMemory_Outstanding());
}
Exemple #6
0
static bool
_MetisLRUContentStore_Destructor(_MetisLRUContentStore **storePtr)
{
    _MetisLRUContentStore *store = *storePtr;
   
    _destroyIndexes(store);
    metisLogger_Release(&store->logger);
   
    return true;
}
void
metisHopByHopFragmenter_Release(MetisHopByHopFragmenter **fragmenterPtr)
{
    MetisHopByHopFragmenter *fragmenter = *fragmenterPtr;
    parcEventBuffer_Destroy(&fragmenter->currentReceiveBuffer);
    parcRingBuffer1x1_Release(&fragmenter->sendQueue);
    parcRingBuffer1x1_Release(&fragmenter->receiveQueue);
    metisLogger_Release(&fragmenter->logger);
    parcMemory_Deallocate((void **) fragmenterPtr);
}
Exemple #8
0
LONGBOW_TEST_CASE(Global, metisMessage_HasKeyId_False)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromArray(metisTestDataV0_InterestWithName, sizeof(metisTestDataV0_InterestWithName), 1, 2, logger);
    metisLogger_Release(&logger);
    bool hasKeyId = metisMessage_HasKeyId(message);
    assertFalse(hasKeyId, "Message without a keyid says it does");
    metisMessage_Release(&message);
}
Exemple #9
0
LONGBOW_TEST_CASE(Global, metisMessage_HasKeyId_True)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromArray(metisTestDataV0_EncodedObject, sizeof(metisTestDataV0_EncodedObject), 1, 2, logger);
    metisLogger_Release(&logger);
    bool hasKeyId = metisMessage_HasKeyId(message);
    assertTrue(hasKeyId, "Message with a keyid says it does not");
    metisMessage_Release(&message);
}
Exemple #10
0
LONGBOW_TEST_CASE(Global, metisMessage_HasContentObjectHash_False)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromArray(metisTestDataV0_EncodedInterest, sizeof(metisTestDataV0_EncodedInterest), 1, 2, logger);
    metisLogger_Release(&logger);
    bool hasHash = metisMessage_HasContentObjectHash(message);
    assertTrue(hasHash, "Message without a content object hash says it does");
    metisMessage_Release(&message);
}
Exemple #11
0
void
metisDispatcher_Destroy(MetisDispatcher **dispatcherPtr)
{
    assertNotNull(dispatcherPtr, "Parameter must be non-null double pointer");
    assertNotNull(*dispatcherPtr, "Parameter must dereference to non-null pointer");
    MetisDispatcher *dispatcher = *dispatcherPtr;

    metisLogger_Release(&dispatcher->logger);
    parcEventScheduler_Destroy(&(dispatcher->Base));
    parcMemory_Deallocate((void **) &dispatcher);
    *dispatcherPtr = NULL;
}
Exemple #12
0
LONGBOW_TEST_CASE(Global, metisMessage_GetHopLimit)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromArray(metisTestDataV0_EncodedInterest, sizeof(metisTestDataV0_EncodedInterest), 1, 2, logger);
    metisLogger_Release(&logger);

    uint8_t hoplimit = metisMessage_GetHopLimit(message);
    assertTrue(hoplimit == 32, "Wrong hop limit, got %u expected %u.", hoplimit, 32);

    metisMessage_Release(&message);
}
Exemple #13
0
LONGBOW_TEST_CASE(Global, metisMessage_KeyIdEquals_DifferentValue)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *a = metisMessage_CreateFromArray(metisTestDataV0_EncodedObject, sizeof(metisTestDataV0_EncodedObject), 1, 2, logger);
    MetisMessage *b = metisMessage_CreateFromArray(metisTestDataV0_SecondInterest, sizeof(metisTestDataV0_SecondInterest), 1, 2, logger);
    metisLogger_Release(&logger);

    assertFalse(metisMessage_KeyIdEquals(a, b), "Messages with differnt keyids did compared equal");
    metisMessage_Release(&a);
    metisMessage_Release(&b);
}
Exemple #14
0
LONGBOW_TEST_CASE(Global, metisMessage_CreateFromArray_BadMessage)
{
    // Invalid version
    char message_str[] = "\xFFOnce upon a time, in a stack far away, a dangling pointer found its way to the top of the heap.";
    printf("metisMessage_CreateFromArray_BadMessage attempting to process a bad message which should report an error:\n");
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromArray((uint8_t *) message_str, sizeof(message_str), 1, 2, logger);
    metisLogger_Release(&logger);

    assertNull(message, "Got null from metisMessage_CreateFromArray");
}
Exemple #15
0
LONGBOW_TEST_CASE(Global, metisMessage_HasHopLimit_False)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromArray(metisTestDataV0_EncodedInterest_no_hoplimit, sizeof(metisTestDataV0_EncodedInterest_no_hoplimit), 1, 2, logger);
    metisLogger_Release(&logger);

    bool hasHopLimit = metisMessage_HasHopLimit(message);
    assertFalse(hasHopLimit, "Message without a hop limit says it does.");

    metisMessage_Release(&message);
}
Exemple #16
0
LONGBOW_TEST_CASE(Global, metisMessage_GetMessageType)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromArray(metisTestDataV0_EncodedObject, sizeof(metisTestDataV0_EncodedObject), 1, 2, logger);
    metisLogger_Release(&logger);
    MetisMessagePacketType type = metisMessage_GetType(message);

    assertTrue(type == MetisMessagePacketType_ContentObject, "wrong type, expected %u got %u", MetisMessagePacketType_ContentObject, type);

    metisMessage_Release(&message);
}
Exemple #17
0
LONGBOW_TEST_CASE(Global, metisMessage_ObjectHashEquals_IsEqual_Lazy)
{
    // create messages from content objects, as those are lazy computed
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *a = metisMessage_CreateFromArray(metisTestDataV0_EncodedObject, sizeof(metisTestDataV0_EncodedObject), 1, 2, logger);
    MetisMessage *b = metisMessage_CreateFromArray(metisTestDataV0_EncodedObject, sizeof(metisTestDataV0_EncodedObject), 1, 2, logger);
    metisLogger_Release(&logger);

    assertTrue(metisMessage_ObjectHashEquals(a, b), "Messages with equal ContentObjectHash did not compare");
    metisMessage_Release(&a);
    metisMessage_Release(&b);
}
Exemple #18
0
LONGBOW_TEST_CASE(Global, metisMessage_ObjectHashEquals_IsNotEqual)
{
    // create messages from different content objects
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *a = metisMessage_CreateFromArray(metisTestDataV0_EncodedObject, sizeof(metisTestDataV0_EncodedObject), 1, 2, logger);
    MetisMessage *b = metisMessage_CreateFromArray(metisTestDataV0_SecondObject, sizeof(metisTestDataV0_SecondObject), 1, 2, logger);
    metisLogger_Release(&logger);

    assertFalse(metisMessage_ObjectHashEquals(a, b), "Messages with unequal ContentObjectHash compared as equal");
    metisMessage_Release(&a);
    metisMessage_Release(&b);
}
Exemple #19
0
LONGBOW_TEST_CASE(Global, metisMessage_HasInterestLifetime)
{
    PARCEventBuffer *buff = parcEventBuffer_Create();
    parcEventBuffer_Append(buff, metisTestDataV1_Interest_AllFields, sizeof(metisTestDataV1_Interest_AllFields));
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromBuffer(1, 2, buff, logger);
    metisLogger_Release(&logger);

    assertTrue(metisMessage_HasInterestLifetime(message), "Should have returned true for interest lifetime");

    metisMessage_Release(&message);
}
Exemple #20
0
LONGBOW_TEST_CASE(Global, metisMessage_CreateFromArray)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromArray(metisTestDataV0_EncodedObject, sizeof(metisTestDataV0_EncodedObject), 1, 2, logger);
    metisLogger_Release(&logger);


    assertNotNull(message, "Got null from metisMessage_CreateFromArray");
    assertTrue(message->ingressConnectionId == 1, "IngressConnectionId wrong, expected %d got %u", 1, message->ingressConnectionId);
    assertTrue(message->receiveTime == 2, "receiveTime wrong, expected %u got %" PRIu64, 2, message->receiveTime);

    metisMessage_Release(&message);
}
Exemple #21
0
LONGBOW_TEST_CASE(Global, metisMessage_GetName)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromArray(metisTestDataV0_EncodedObject, sizeof(metisTestDataV0_EncodedObject), 1, 2, logger);
    metisLogger_Release(&logger);
    MetisTlvName *name = metisMessage_GetName(message);
    MetisTlvName *truth = metisTlvName_Create(&metisTestDataV0_EncodedObject[metisTestDataV0_EncodedObject_name.offset], metisTestDataV0_EncodedObject_name.length);

    assertTrue(metisTlvName_Equals(truth, name), "Did not get back the right name");

    metisTlvName_Release(&truth);
    metisMessage_Release(&message);
}
Exemple #22
0
LONGBOW_TEST_CASE(Global, metisMessage_ObjectHashHashCode_Lazy)
{
    // create messages from content object, as those are precomputed
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *a = metisMessage_CreateFromArray(metisTestDataV0_EncodedObject, sizeof(metisTestDataV0_EncodedObject), 1, 2, logger);
    metisLogger_Release(&logger);

    uint32_t hashcode;
    bool success = metisMessage_GetContentObjectHashHash(a, &hashcode);
    assertTrue(success, "Returned false trying to get hash of contentobject hash");

    metisMessage_Release(&a);
}
Exemple #23
0
void
metisConfiguration_Destroy(MetisConfiguration **configPtr)
{
    assertNotNull(configPtr, "Parameter must be non-null double poitner");
    assertNotNull(*configPtr, "Parameter must dereference to non-null pointer");

    MetisConfiguration *config = *configPtr;
    metisLogger_Release(&config->logger);
    if (config->cli != NULL) {
        metisCommandLineInterface_Destroy(&config->cli);
    }

    metisSymbolicNameTable_Destroy(&config->symbolicNameTable);
    parcMemory_Deallocate((void **) &config);
    *configPtr = NULL;
}
Exemple #24
0
LONGBOW_TEST_CASE(Global, metisMessage_Create_InterestV1)
{
    PARCEventBuffer *buff = parcEventBuffer_Create();
    parcEventBuffer_Append(buff, metisTestDataV1_Interest_AllFields, sizeof(metisTestDataV1_Interest_AllFields));
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromBuffer(1, 2, buff, logger);
    metisLogger_Release(&logger);

    assertNotNull(message, "Got null from metisMessage_CreateFromBuffer");
    assertTrue(message->ingressConnectionId == 1, "IngressConnectionId wrong, expected %d got %u", 1, message->ingressConnectionId);
    assertTrue(message->receiveTime == 2, "receiveTime wrong, expected %u got %" PRIu64, 2, message->receiveTime);

    metisMessage_Release(&message);
}
Exemple #25
0
LONGBOW_TEST_CASE(Global, metisMessage_SetGetRecommendedCacheTime)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);

    // Note: Assumes metisTestDataV0_EncodedObject doesn't have RCT.
    MetisMessage *message = metisMessage_CreateFromArray(metisTestDataV0_EncodedObject, sizeof(metisTestDataV0_EncodedObject), 1, 2, logger);
    metisLogger_Release(&logger);

    uint64_t time = 12345;
    metisMessage_SetRecommendedCacheTimeTicks(message, time);
    assertTrue(time == metisMessage_GetRecommendedCacheTimeTicks(message), "Retrieved unexpected RCT");

    metisMessage_Release(&message);
}
Exemple #26
0
LONGBOW_TEST_CASE(Global, metisMessage_GetInterestLifetimeTicks)
{
    PARCEventBuffer *buff = parcEventBuffer_Create();
    parcEventBuffer_Append(buff, metisTestDataV1_Interest_AllFields, sizeof(metisTestDataV1_Interest_AllFields));
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromBuffer(1, 2, buff, logger);
    metisLogger_Release(&logger);

    // don't check actual value.  It will vary based on METISHZ and rouding errors due to integer math
    MetisTicks ticks = metisMessage_GetInterestLifetimeTicks(message);
    assertTrue(ticks > 0, "Should have gotten positive value for interest lifetime ticks");

    metisMessage_Release(&message);
}
Exemple #27
0
LONGBOW_TEST_CASE(Global, metisMessage_GetKeyIdHash)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromArray(metisTestDataV0_EncodedObject, sizeof(metisTestDataV0_EncodedObject), 1, 2, logger);
    metisLogger_Release(&logger);

    uint32_t truthhash = parcHash32_Data(&metisTestDataV0_EncodedObject[metisTestDataV0_EncodedObject_keyid.offset], metisTestDataV0_EncodedObject_keyid.length);
    uint32_t testhash;
    bool success = metisMessage_GetKeyIdHash(message, &testhash);

    assertTrue(success, "Failed metisMessage_GetKeyIdHash, returned false");
    assertTrue(truthhash == testhash, "Hash compared wrong, expected %08X, got %08X", truthhash, testhash);

    metisMessage_Release(&message);
}
Exemple #28
0
LONGBOW_TEST_CASE(Global, metisMessage_Length)
{
    char message_str[] = "\x00Once upon a time, in a stack far away, a dangling pointer found its way to the top of the heap.";

    PARCEventBuffer *buff = parcEventBuffer_Create();
    parcEventBuffer_Append(buff, message_str, sizeof(message_str));

    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);
    MetisMessage *message = metisMessage_CreateFromBuffer(1, 2, buff, logger);
    metisLogger_Release(&logger);

    assertNotNull(message, "Got null from metisMessage_CreateFromBuffer");
    size_t length = metisMessage_Length(message);
    assertTrue(length == sizeof(message_str), "Wrong length, expected %zu got %zu", sizeof(message_str), length);
    metisMessage_Release(&message);
}
Exemple #29
0
static void
_metisStandardPIT_Destroy(MetisPIT **pitPtr)
{
    assertNotNull(pitPtr, "Parameter must be non-null double pointer");
    assertNotNull(*pitPtr, "Parameter must dereference to non-null pointer");

    MetisStandardPIT *pit = metisPIT_Closure(*pitPtr);

    if (metisLogger_IsLoggable(pit->logger, MetisLoggerFacility_Processor, PARCLogLevel_Debug)) {
        metisLogger_Log(pit->logger, MetisLoggerFacility_Processor, PARCLogLevel_Debug, __func__,
                        "PIT %p destroyed",
                        (void *) pit);
    }

    metisMatchingRulesTable_Destroy(&pit->table);
    metisLogger_Release(&pit->logger);
    parcMemory_Deallocate(pitPtr);
}
static MetisContentStoreInterface *
_createLRUContentStore(size_t capacity)
{
    PARCLogReporter *reporter = parcLogReporterTextStdout_Create();
    MetisLogger *logger = metisLogger_Create(reporter, parcClock_Wallclock());
    parcLogReporter_Release(&reporter);

    metisLogger_SetLogLevel(logger, MetisLoggerFacility_Processor, PARCLogLevel_Debug);

    MetisContentStoreConfig config = {
        .objectCapacity = capacity,
    };

    MetisContentStoreInterface *store = metisLRUContentStore_Create(&config, logger);

    metisLogger_Release(&logger);

    return store;
}