aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-07-27 20:16:07 +0200
committerMattias Andrée <maandree@operamail.com>2014-07-27 20:16:07 +0200
commit88ff17de1673575b247da3374dedf8561716238e (patch)
tree1302ffb5363724ece99148022fb897a8d65ef5c2 /src
parentmark temporary prints (diff)
downloadmds-88ff17de1673575b247da3374dedf8561716238e.tar.gz
mds-88ff17de1673575b247da3374dedf8561716238e.tar.bz2
mds-88ff17de1673575b247da3374dedf8561716238e.tar.xz
fix multiple clients bug: minor bug in linked_list caused removal of old clients + add dump method for linked list
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r--src/libmdsserver/linked-list.c37
-rw-r--r--src/libmdsserver/linked-list.h10
-rw-r--r--src/mds-server/interceptors.c3
3 files changed, 46 insertions, 4 deletions
diff --git a/src/libmdsserver/linked-list.c b/src/libmdsserver/linked-list.c
index 4755ad4..066414a 100644
--- a/src/libmdsserver/linked-list.c
+++ b/src/libmdsserver/linked-list.c
@@ -342,7 +342,7 @@ ssize_t linked_list_insert_before(linked_list_t* restrict this, size_t value, ss
if (node == LINKED_LIST_UNUSED)
return LINKED_LIST_UNUSED;
this->values[node] = value;
- this->previous[node] = this->next[successor];
+ this->previous[node] = this->previous[successor];
this->previous[successor] = node;
this->next[node] = successor;
this->next[this->previous[node]] = node;
@@ -469,3 +469,38 @@ int linked_list_unmarshal(linked_list_t* restrict this, char* restrict data)
return 0;
}
+
+/**
+ * Print the content of the list
+ *
+ * @param this The list
+ * @param output Output file
+ */
+void linked_list_dump(linked_list_t* restrict this, FILE* output)
+{
+ ssize_t i;
+ size_t j;
+ fprintf(output, "======= LINKED LIST DUMP =======\n");
+ fprintf(output, "Capacity: %lu\n", this->capacity);
+ fprintf(output, "End: %lu\n", this->end);
+ fprintf(output, "Reuse head: %lu\n", this->reuse_head);
+ fprintf(output, "Edge: %li\n", this->edge);
+ fprintf(output, "--------------------------------\n");
+ fprintf(output, "Node table (Next, Prev, Value):\n");
+ i = this->edge;
+ fprintf(output, " %li: %li, %li, %lu\n", i, this->next[i], this->previous[i], this->values[i]);
+ foreach_linked_list_node((*this), i)
+ fprintf(output, " %li: %li, %li, %lu\n", i, this->next[i], this->previous[i], this->values[i]);
+ i = this->edge;
+ fprintf(output, " %li: %li, %li, %lu\n", i, this->next[i], this->previous[i], this->values[i]);
+ fprintf(output, "--------------------------------\n");
+ fprintf(output, "Raw node table:\n");
+ for (j = 0; j < this->end; j++)
+ fprintf(output, " %lu: %li, %li, %lu\n", i, this->next[i], this->previous[i], this->values[i]);
+ fprintf(output, "--------------------------------\n");
+ fprintf(output, "Reuse stack:\n");
+ for (j = 0; j < this->reuse_head; j++)
+ fprintf(output, " %lu: %li\n", j, this->reusable[j]);
+ fprintf(output, "================================\n");
+}
+
diff --git a/src/libmdsserver/linked-list.h b/src/libmdsserver/linked-list.h
index 5b1a44d..e2ec884 100644
--- a/src/libmdsserver/linked-list.h
+++ b/src/libmdsserver/linked-list.h
@@ -39,6 +39,7 @@
#include <stdlib.h>
#include <stdint.h>
+#include <stdio.h>
@@ -276,5 +277,14 @@ int linked_list_unmarshal(linked_list_t* restrict this, char* restrict data);
for (node = list.edge; node = list.next[node], node != list.edge;)
+/**
+ * Print the content of the list
+ *
+ * @param this The list
+ * @param output Output file
+ */
+void linked_list_dump(linked_list_t* restrict this, FILE* output);
+
+
#endif
diff --git a/src/mds-server/interceptors.c b/src/mds-server/interceptors.c
index ac64945..552d7a1 100644
--- a/src/mds-server/interceptors.c
+++ b/src/mds-server/interceptors.c
@@ -265,7 +265,6 @@ queued_interception_t* get_interceptors(client_t* sender, size_t* hashes, char**
/* Count clients. */
foreach_linked_list_node (client_list, node)
n++;
- eprintf("n: %lu", n); /* TODO temporary */
/* Allocate interceptor list. */
if (xmalloc(interceptions, n, queued_interception_t))
@@ -281,7 +280,6 @@ queued_interception_t* get_interceptors(client_t* sender, size_t* hashes, char**
{
int r = find_matching_condition(client, hashes, keys, headers, count,
interceptions + interceptions_count);
- eprintf("%i", r); /* TODO temporary */
if (r == -1)
{
free(interceptions);
@@ -293,7 +291,6 @@ queued_interception_t* get_interceptors(client_t* sender, size_t* hashes, char**
}
}
- eprint(""); /* TODO temporary */
*interceptions_count_out = interceptions_count;
return interceptions;
}