diff options
author | Adam Chlipala <adam@chlipala.net> | 2013-12-25 13:11:43 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2013-12-25 13:11:43 -0500 |
commit | aea9e6db8a7a72dd555913a38cb893d247c3c09e (patch) | |
tree | 36a6ce08dd187e10bfb353692a0b2cef5c4c64cc /src | |
parent | 2555c24cbd50d7afc517f7c9e6cac77ba87f0d99 (diff) |
Tweaking handling of database transactions
Diffstat (limited to 'src')
-rw-r--r-- | src/c/cgi.c | 9 | ||||
-rw-r--r-- | src/c/fastcgi.c | 9 | ||||
-rw-r--r-- | src/c/http.c | 9 | ||||
-rw-r--r-- | src/c/urweb.c | 8 |
4 files changed, 21 insertions, 14 deletions
diff --git a/src/c/cgi.c b/src/c/cgi.c index f1482589..539b83c2 100644 --- a/src/c/cgi.c +++ b/src/c/cgi.c @@ -134,10 +134,11 @@ void uw_copy_client_data(void *dst, void *src) { } void uw_do_expunge(uw_context ctx, uw_Basis_client cli, void *data) { - do { - uw_ensure_transaction(ctx); - uw_get_app(ctx)->expunger(ctx, cli); - } while (uw_commit(ctx) && (uw_rollback(ctx, 1), 1)); + uw_ensure_transaction(ctx); + uw_get_app(ctx)->expunger(ctx, cli); + + if (uw_commit(ctx)) + uw_error(ctx, UNLIMITED_RETRY, "Rerunning expunge transaction"); } void uw_post_expunge(uw_context ctx, void *data) { diff --git a/src/c/fastcgi.c b/src/c/fastcgi.c index bbda0f57..5c80d3ae 100644 --- a/src/c/fastcgi.c +++ b/src/c/fastcgi.c @@ -632,10 +632,11 @@ void uw_copy_client_data(void *dst, void *src) { } void uw_do_expunge(uw_context ctx, uw_Basis_client cli, void *data) { - do { - uw_ensure_transaction(ctx); - uw_get_app(ctx)->expunger(ctx, cli); - } while (uw_commit(ctx) && (uw_rollback(ctx, 1), 1)); + uw_ensure_transaction(ctx); + uw_get_app(ctx)->expunger(ctx, cli); + + if (uw_commit(ctx)) + uw_error(ctx, UNLIMITED_RETRY, "Rerunning expunge transaction"); } void uw_post_expunge(uw_context ctx, void *data) { diff --git a/src/c/http.c b/src/c/http.c index 9050aaf4..17833ce1 100644 --- a/src/c/http.c +++ b/src/c/http.c @@ -447,10 +447,11 @@ void uw_copy_client_data(void *dst, void *src) { } void uw_do_expunge(uw_context ctx, uw_Basis_client cli, void *data) { - do { - uw_ensure_transaction(ctx); - uw_get_app(ctx)->expunger(ctx, cli); - } while (uw_commit(ctx) && (uw_rollback(ctx, 1), 1)); + uw_ensure_transaction(ctx); + uw_get_app(ctx)->expunger(ctx, cli); + + if (uw_commit(ctx)) + uw_error(ctx, UNLIMITED_RETRY, "Rerunning expunge transaction"); } void uw_post_expunge(uw_context ctx, void *data) { diff --git a/src/c/urweb.c b/src/c/urweb.c index ab6e5b1f..af5cc461 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -3225,7 +3225,11 @@ int uw_rollback(uw_context ctx, int will_retry) { if (ctx->transactionals[i].free) ctx->transactionals[i].free(ctx->transactionals[i].data, will_retry); - return (ctx->app && ctx->transaction_started) ? ctx->app->db_rollback(ctx) : 0; + if (ctx->app && ctx->transaction_started) { + ctx->transaction_started = 0; + return ctx->app->db_rollback(ctx); + } else + return 0; } static const char begin_xhtml[] = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">"; @@ -3461,8 +3465,8 @@ void uw_prune_clients(uw_context ctx) { prev->next = next; else clients_used = next; - uw_reset(ctx); while (fk == UNLIMITED_RETRY) { + uw_reset(ctx); fk = uw_expunge(ctx, c->id, c->data); if (fk == UNLIMITED_RETRY) printf("Unlimited retry during expunge: %s\n", uw_error_message(ctx)); |