summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-04-05 12:05:19 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-04-05 12:05:19 -0400
commit60a994326dab3c23d7dd7ab9ff4538c06329e277 (patch)
treece519c2322c30780cc4a8cfe9f6f772b47719bc1
parent3b3f14a1c2021f307e9290ec8fba64d6c791a93a (diff)
Initialize contexts a little more vigorously
-rw-r--r--src/c/driver.c11
-rw-r--r--src/c/urweb.c6
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) {