Commit 06b58517 authored by Greg Williams's avatar Greg Williams
Browse files

Got multi-put system test working, but there are threading/memory issues to...

Got multi-put system test working, but there are threading/memory issues to solve for PDU allocation
parent ac6e3f5d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ $(OUT_DIR)/byte_array.o: $(LIB_DIR)/byte_array.c $(LIB_DEPS)
$(OUT_DIR)/socket99.o: $(SOCKET99)/socket99.c $(SOCKET99)/socket99.h
	$(CC) -c -o $@ $< $(CFLAGS) -I$(SOCKET99)
$(OUT_DIR)/protobuf-c.o: $(PROTOBUFC)/protobuf-c/protobuf-c.c $(PROTOBUFC)/protobuf-c/protobuf-c.h
	$(CC) -c -o $@ $< -std=c99 -fPIC -g -Wall $(OPTIMIZE) -I$(PROTOBUFC)
	$(CC) -c -o $@ $< -std=c99 -fPIC -g -Wall $(OPTIMIZE) -Wno-unused-parameter -I$(PROTOBUFC)
$(OUT_DIR)/kinetic_client.o: $(LIB_DIR)/kinetic_client.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)

+7 −0
Original line number Diff line number Diff line
require 'kinetic-ruby'

complier = ENV.fetch('CC', 'gcc')
puts "" +
"Configuration:\n" +
"  compiler: #{complier}\n" +
"  version info:\n" +
"    " + `#{complier} --version`.lines.join("    ") + "\n"

KineticRuby::Rake::load_tasks
require 'ceedling'
Ceedling.load_project(config: './project.yml')
+1 −1
Original line number Diff line number Diff line
@@ -22,8 +22,8 @@ typedef struct _ByteArray {

ByteArray ByteArray_Create(void* data, size_t len);
ByteArray ByteArray_CreateWithCString(char* str);
void ByteArray_FillWithDummyData(const ByteArray array);
ByteArray ByteArray_GetSlice(const ByteArray array, size_t start, size_t len);
void ByteArray_FillWithDummyData(const ByteArray array);

/**
 * @brief Structure for an embedded ByteArray as a buffer
+25 −28
Original line number Diff line number Diff line
@@ -45,8 +45,8 @@ void* KineticAllocator_NewItem(KineticList* list, size_t size)
    }
    list->last = newItem;

    LOGF("Allocated new list item @ 0x%0llX w/data @ 0x%0llX",
         (long long)newItem, (long long)&newItem->data);
    // LOGF("Allocated new list item @ 0x%0llX w/data @ 0x%0llX",
    //      (long long)newItem, (long long)&newItem->data);

    return newItem->data;
}
@@ -63,39 +63,39 @@ void KineticAllocator_FreeItem(KineticList* list, void* item)
            cur = cur->next;
        }
    }
    LOG("  Done searching for item list item");
    // LOG("  Done searching for item list item");

    if ((cur != NULL) && (cur->data == item)) {
        LOG("  item found! freeing it.");
        // LOG("  item found! freeing it.");

        // Handle PDU list emptied
        if (cur->previous == NULL) {
            LOG("  At start of list.");
            // LOG("  At start of list.");
            if (cur->next == NULL) {
                LOG("  Making it empty, since all deallocated!");
                // LOG("  Making it empty, since all deallocated!");
                list->start = NULL;
                list->last = NULL;
            }
            else {
                LOG("  Moving current item to head, since head deallocated!");
                // LOG("  Moving current item to head, since head deallocated!");
                list->start = cur->next;
                list->start->previous = NULL;
            }
        }
        else {
            // Relink from previous to next, if avaliable
            LOG("  Not at list start, so relinking list to free item.");
            // LOG("  Not at list start, so relinking list to free item.");
            if (cur->previous->next != NULL) {
                LOG("  Relinking previous to next");
                // LOG("  Relinking previous to next");
                if (cur->next != NULL) {
                    LOG("    next being reset!");
                    // LOG("    next being reset!");
                    cur->previous->next = cur->next;
                }
                else {
                    list->last = cur->previous;
                    list->last->next = NULL;
                    LOGF("    next is NULL. End of list now @ 0x%0llX",
                         (long long)list->last);
                    // LOGF("    next is NULL. End of list now @ 0x%0llX",
                    //      (long long)list->last);
                }
            }
            else {
@@ -104,8 +104,8 @@ void KineticAllocator_FreeItem(KineticList* list, void* item)
            }
        }

        LOGF("  Freeing item @ 0x%0llX, item @ 0x%0llX",
             (long long)cur, (long long)&cur->data);
        // LOGF("  Freeing item @ 0x%0llX, item @ 0x%0llX",
        //      (long long)cur, (long long)&cur->data);
        free(cur->data);
        cur->data = NULL;
        free(cur);
@@ -117,29 +117,29 @@ void KineticAllocator_FreeList(KineticList* list)
{
    LOG_LOCATION;
    if (list != NULL) {
        LOG("Freeing list of all items...");
        LOG("Freeing list of all items");
        KineticListItem* current = list->start;

        while (current->next != NULL) {
            LOG("Advancing to next list item...");
            // LOG("Advancing to next list item...");
            current = current->next;
        }

        while (current != NULL) {
            LOG("  Current item not freed!");
            LOGF("  DEALLOCATING item: 0x%0llX, data: 0x%llX, prev: 0x%0llX",
                 (long long)current, (long long)&current->data, (long long)current->previous);
            // LOG("  Current item not freed!");
            // LOGF("  DEALLOCATING item: 0x%0llX, data: 0x%llX, prev: 0x%0llX",
            //     (long long)current, (long long)&current->data, (long long)current->previous);
            KineticListItem* curItem = current;
            KineticListItem* prevItem = current->previous;
            if (curItem != NULL) {
                LOG("  Freeing list item");
                // LOG("  Freeing list item");
                if (curItem->data != NULL) {
                    free(curItem->data);
                }
                free(curItem);
            }
            current = prevItem;
            LOGF("  on to prev=0x%llX", (long long)current);
            // LOGF("  on to prev=0x%llX", (long long)current);
        }
    }
    else {
@@ -161,18 +161,15 @@ KineticPDU* KineticAllocator_NewPDU(void)
        LOG("Failed allocating new PDU!");
        return NULL;
    }

    assert(newPDU->proto == NULL);

    LOGF("Allocated new PDU @ 0x%0llX", (long long)newPDU);

    // LOGF("Allocated new PDU @ 0x%0llX", (long long)newPDU);
    return newPDU;
}

void KineticAllocator_FreePDU(KineticPDU* pdu)
{
    if ((pdu->proto != NULL) && pdu->protobufDynamicallyExtracted) {
        LOG("Freeing dynamically allocated protobuf");
        // LOG("Freeing dynamically allocated protobuf");
        KineticProto__free_unpacked(pdu->proto, NULL);
    };
    KineticAllocator_FreeItem(&PDUList, (void*)pdu);
@@ -203,7 +200,7 @@ bool KineticAllocator_ValidateAllMemoryFreed(void)
{
    bool empty = (PDUList.start == NULL);
    LOG_LOCATION;
    LOGF("  PDUList: 0x%0llX, empty=%s",
         (long long)PDUList.start, empty ? "true" : "false");
    // LOGF("  PDUList: 0x%0llX, empty=%s",
         // (long long)PDUList.start, empty ? "true" : "false");
    return empty;
}
+2 −2
Original line number Diff line number Diff line
@@ -58,8 +58,8 @@ static KineticStatus KineticClient_ExecuteOperation(KineticOperation* operation)
    LOGF("Executing operation: 0x%llX", operation);
    if (operation->request->entry.value.array.data != NULL
        && operation->request->entry.value.bytesUsed > 0) {
        KineticLogger_LogByteBuffer("  Sending PDU w/value:",
                                    operation->request->entry.value);
        LOGF("  Sending PDU w/value (%zu bytes)",
            operation->request->entry.value.bytesUsed);
    }
    else {
        LOG("  Sending PDU w/o value");
Loading