From ec0e365e2faa26e78a7fa7b81cbf941f5545ef1a Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 2 Apr 2009 11:42:26 -0400 Subject: On start-up, delete/nullify rows mentioning clients or channels --- src/c/driver.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/c/driver.c') 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! -- cgit v1.2.3