summaryrefslogtreecommitdiff
path: root/src/c/driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/c/driver.c')
-rw-r--r--src/c/driver.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/c/driver.c b/src/c/driver.c
index 14d08b57..52999da3 100644
--- a/src/c/driver.c
+++ b/src/c/driver.c
@@ -69,7 +69,7 @@ static int try_rollback(uw_context ctx) {
static void *worker(void *data) {
int me = *(int *)data, retries_left = MAX_RETRIES;
- uw_context ctx = uw_init(0, 0, 1024, 0);
+ uw_context ctx = uw_init();
while (1) {
failure_kind fk = uw_begin_init(ctx);
@@ -278,7 +278,7 @@ static void *worker(void *data) {
}
static void *client_pruner(void *data) {
- uw_context ctx = uw_init(0, 0, 0, 0);
+ uw_context ctx = uw_init();
uw_db_init(ctx);
while (1) {
@@ -296,6 +296,19 @@ static void sigint(int signum) {
exit(0);
}
+static void initialize() {
+ uw_context ctx = uw_init();
+
+ uw_db_init(ctx);
+ if (uw_initialize(ctx) != SUCCESS) {
+ printf("Failed to initialize database!\n");
+ uw_db_rollback(ctx);
+ exit(1);
+ }
+
+ uw_free(ctx);
+}
+
int main(int argc, char *argv[]) {
// The skeleton for this function comes from Beej's sockets tutorial.
int sockfd; // listen on sock_fd
@@ -342,6 +355,8 @@ int main(int argc, char *argv[]) {
}
}
+ initialize();
+
names = calloc(nthreads, sizeof(int));
sockfd = socket(PF_INET, SOCK_STREAM, 0); // do some error checking!