diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-04-05 12:05:19 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-04-05 12:05:19 -0400 |
commit | 85a02505044f45aeff041b30b3a7fcf9cbf76669 (patch) | |
tree | ce519c2322c30780cc4a8cfe9f6f772b47719bc1 /src/c | |
parent | f6559c7555465c479d45529748deb8c15dfa346c (diff) |
Initialize contexts a little more vigorously
Diffstat (limited to 'src/c')
-rw-r--r-- | src/c/driver.c | 11 | ||||
-rw-r--r-- | src/c/urweb.c | 6 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/c/driver.c b/src/c/driver.c index 44465cc3..c5e1ba33 100644 --- a/src/c/driver.c +++ b/src/c/driver.c @@ -306,12 +306,19 @@ static void sigint(int signum) { 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 --git a/src/c/urweb.c b/src/c/urweb.c index 1b3cfb1d..67985d35 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -346,6 +346,10 @@ uw_context uw_init() { ctx->timeout = uw_timeout; + ctx->client = NULL; + + ctx->error_message[0] = 0; + return ctx; } @@ -1872,7 +1876,7 @@ int uw_db_rollback(uw_context); 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) { |