Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kejistan/CS425-MP2
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Crawford committed Dec 4, 2011
2 parents 691a55c + 4d08a90 commit 961a922
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion node.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,6 @@ void message_free(message_t *message)
/**
* Handles recieved node to node messages by either forwarding the message closer
* to its destination node, or if it is the destination by handling the contents
* @todo implement finger table correction
*/
void message_recieve(const char *buf, port_t source_port)
{
Expand Down Expand Up @@ -773,6 +772,9 @@ int main(int argc, char *argv[])

dbg_init();

message_queue = queue_init();
recycle_queue = queue_init();

init_socket();

dbg("Initalized, port: %d, id %d\n", my_port, my_id);
Expand Down
7 changes: 5 additions & 2 deletions queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

queue_t *queue_init(void)
{
return calloc(sizeof(queue_t), 0);
return calloc(sizeof(queue_t), 1);
}

void queue_free(queue_t *queue)
Expand All @@ -23,13 +23,15 @@ void queue_free(queue_t *queue)

int queue_empty(queue_t *queue)
{
return !!queue->head;
return !queue->head;
}

void enqueue(queue_t *queue, message_t *message)
{
message_t *current = queue->head;

assert(!message->next);

++queue->size;

if (!current) {
Expand All @@ -52,5 +54,6 @@ message_t *dequeue(queue_t *queue)
--queue->size;
}

current->next = NULL;
return current;
}

0 comments on commit 961a922

Please sign in to comment.