# HG changeset patch # User Adam Chlipala # Date 1238947519 14400 # Node ID db6ab16cd8f38bb25145b55146e4a46e905ea9b2 # Parent 4e260887d8f2d942df2ffcd544acfccc7a520da7 Initialize contexts a little more vigorously diff -r 4e260887d8f2 -r db6ab16cd8f3 src/c/driver.c --- a/src/c/driver.c Sun Apr 05 11:48:55 2009 -0400 +++ b/src/c/driver.c Sun Apr 05 12:05:19 2009 -0400 @@ -306,12 +306,19 @@ static void initialize() { uw_context ctx = new_context(); + failure_kind fk; if (!ctx) exit(1); - if (uw_initialize(ctx) != SUCCESS) { - printf("Failed to initialize database!\n"); + for (fk = uw_initialize(ctx); fk == UNLIMITED_RETRY; fk = uw_initialize(ctx)) { + printf("Unlimited retry during init: %s\n", uw_error_message(ctx)); + uw_db_rollback(ctx); + uw_reset(ctx); + } + + if (fk != SUCCESS) { + printf("Failed to initialize database! %s\n", uw_error_message(ctx)); uw_db_rollback(ctx); exit(1); } diff -r 4e260887d8f2 -r db6ab16cd8f3 src/c/urweb.c --- a/src/c/urweb.c Sun Apr 05 11:48:55 2009 -0400 +++ b/src/c/urweb.c Sun Apr 05 12:05:19 2009 -0400 @@ -346,6 +346,10 @@ ctx->timeout = uw_timeout; + ctx->client = NULL; + + ctx->error_message[0] = 0; + return ctx; } @@ -1872,7 +1876,7 @@ void uw_commit(uw_context ctx) { unsigned i; - if (uw_db_commit(ctx)) + if (uw_db_commit(ctx)) uw_error(ctx, FATAL, "Error running SQL COMMIT"); for (i = 0; i < ctx->used_deltas; ++i) {