diff src/c/driver.c @ 687:a3ddf05fb3e3

On start-up, delete/nullify rows mentioning clients or channels
author Adam Chlipala <adamc@hcoop.net>
date Thu, 02 Apr 2009 11:42:26 -0400
parents 9a2c18dab11d
children 9b29ce0babb8
line wrap: on
line diff
--- a/src/c/driver.c	Thu Apr 02 10:57:14 2009 -0400
+++ b/src/c/driver.c	Thu Apr 02 11:42:26 2009 -0400
@@ -69,7 +69,7 @@
 
 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 *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 @@
   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 @@
     }
   }
 
+  initialize();
+
   names = calloc(nthreads, sizeof(int));
 
   sockfd = socket(PF_INET, SOCK_STREAM, 0); // do some error checking!