comparison src/c/urweb.c @ 2177:00cf8214c2e3

Switching to a more dynamic method of handling database reconnection, restarting transactions
author Adam Chlipala <adam@chlipala.net>
date Sat, 17 Oct 2015 11:08:12 -0400
parents d2a98983f502
children c76a9712334c
comparison
equal deleted inserted replaced
2176:d2a98983f502 2177:00cf8214c2e3
809 809
810 if (!ctx->db) 810 if (!ctx->db)
811 uw_error(ctx, FATAL, "Error reopening database connection"); 811 uw_error(ctx, FATAL, "Error reopening database connection");
812 } 812 }
813 813
814 int uw_try_reconnecting_if_at_most_one(uw_context ctx) { 814 void uw_try_reconnecting_and_restarting(uw_context ctx) {
815 if (ctx->at_most_one_query) { 815 uw_try_reconnecting(ctx);
816 uw_try_reconnecting(ctx); 816 uw_error(ctx, UNLIMITED_RETRY, "Restarting transaction after fixing database connection");
817 return 1;
818 } else
819 return 0;
820 } 817 }
821 818
822 void uw_ensure_transaction(uw_context ctx) { 819 void uw_ensure_transaction(uw_context ctx) {
823 if (!ctx->transaction_started && !ctx->at_most_one_query) { 820 if (!ctx->transaction_started && !ctx->at_most_one_query) {
824 if (!ctx->db || ctx->app->db_begin(ctx, ctx->could_write_db)) { 821 if (!ctx->db || ctx->app->db_begin(ctx, ctx->could_write_db)) {