summaryrefslogtreecommitdiffstats
path: root/server/tree.h
blob: e6eea8497985d1a44b11ddf85e2fe30579943654 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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);