diff src/c/urweb.c @ 1941:9f3597979e98

Tweaking handling of database transactions
author Adam Chlipala <adam@chlipala.net>
date Wed, 25 Dec 2013 13:11:43 -0500
parents c52365a4ce41
children a671e5258a2c
line wrap: on
line diff
--- a/src/c/urweb.c	Wed Dec 25 12:02:42 2013 -0500
+++ b/src/c/urweb.c	Wed Dec 25 13:11:43 2013 -0500
@@ -3225,7 +3225,11 @@
     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 @@
         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));