-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaster.c
40 lines (30 loc) · 855 Bytes
/
master.c
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
38
39
40
#include "aixen.h"
#include "master.h"
static void *pt_spawn_master (void *retval) {
int *ret = retval;
*ret = master ();
return retval;
}
static inline int master (void) {
int x;
// db initialization
struct lcb_create_st db_options = { 0 };
for (x = 0; x < config.ipport.master.db.count; x++) {
// preserve the last iteration
assert ((char *last = strdup (db_options.v.v0.host)));
// iterate and build the db host string
asprintf ((char **) &(db_options.v.v0.host), "%s%s:%i;", last,
config.ipport.master.db.address[x].host,
config.ipport.master.db.address[x].port);
assert (db_options.v.v0.host);
free (last);
}
lcb_t db_instance;
lcb_error_t err = lcb_create (&db_instance, &options);
assert (err == LCB_SUCCESS);
// fill in later
// cleanup
lcb_destroy (instance);
free (db_options.v.v0.host);
return 0;
}