summaryrefslogtreecommitdiffstats
path: root/server/tree.h
diff options
context:
space:
mode:
Diffstat (limited to 'server/tree.h')
-rw-r--r--server/tree.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/server/tree.h b/server/tree.h
new file mode 100644
index 0000000..e6eea84
--- /dev/null
+++ b/server/tree.h
@@ -0,0 +1,37 @@
+/*
+ * server/tree.h - Mechanism to store Datasets in binary trees.
+ */
+
+
+/*
+ * This structure represents a Dataset along with its config file and
+ * file descriptor. This type of items will be stored in a binary
+ * tree. The key to this structure is the Dataset's Volume-ID and
+ * Release-ID (they must be unique in each server instance).
+ */
+typedef struct node {
+ dataset_t *ds;
+ char path[FILE_NAME_MAX];
+ int fd;
+ int servers;
+ dnbd2_server_t server[ALT_SERVERS_MAX];
+} node_t;
+
+
+/*
+ * Returns: 0 on success or -1 on failure.
+ */
+int tree_insert(node_t *data, void **tree);
+
+
+/*
+ * Returns: Pointer to item on search-hit or NULL on search-miss.
+ */
+node_t *tree_find(node_t *data, void **tree);
+
+
+/*
+ * Free all resources used by the tree. Useful when reloading
+ * datasets.
+ */
+void tree_destroy(void **tree);