diff src/c/urweb.c @ 684:f0224c7f12bb

Expunging nullable fields
author Adam Chlipala <adamc@hcoop.net>
date Sun, 29 Mar 2009 14:13:50 -0400
parents 9a2c18dab11d
children c73c5fe72388
line wrap: on
line diff
--- a/src/c/urweb.c	Sun Mar 29 13:30:01 2009 -0400
+++ b/src/c/urweb.c	Sun Mar 29 14:13:50 2009 -0400
@@ -1869,8 +1869,13 @@
 static failure_kind uw_expunge(uw_context ctx, uw_Basis_client cli) {
   int r = setjmp(ctx->jmp_buf);
 
-  if (r == 0)
+  if (r == 0) {
+    if (uw_db_begin(ctx))
+      uw_error(ctx, FATAL, "Error running SQL BEGIN");
     uw_expunger(ctx, cli);
+    if (uw_db_commit(ctx))
+      uw_error(ctx, FATAL, "Error running SQL COMMIT");
+  }
 
   return r;
 }
@@ -1892,16 +1897,20 @@
         prev->next = next;
       else
         clients_used = next;
+      uw_reset(ctx);
       while (fk == UNLIMITED_RETRY) {
-        uw_reset(ctx);
         fk = uw_expunge(ctx, c->id);
-        if (fk == SUCCESS) {
-          free_client(c);
-          break;
+        if (fk == UNLIMITED_RETRY) {
+          uw_db_rollback(ctx);
+          printf("Unlimited retry during expunge: %s\n", uw_error_message(ctx));
         }
       }
-      if (fk != SUCCESS)
+      if (fk == SUCCESS)
+        free_client(c);
+      else {
+        uw_db_rollback(ctx);
         printf("Expunge blocked by error: %s\n", uw_error_message(ctx));
+      }
     }
     else
       prev = c;