diff src/c/urweb.c @ 1418:22674ac8ebe6

Proper error handling for periodic tasks
author Adam Chlipala <adam@chlipala.net>
date Sun, 23 Jan 2011 18:16:30 -0500
parents d0786ff9bb22
children eecbffc2b907
line wrap: on
line diff
--- a/src/c/urweb.c	Sun Jan 23 17:27:51 2011 -0500
+++ b/src/c/urweb.c	Sun Jan 23 18:16:30 2011 -0500
@@ -3684,15 +3684,12 @@
 failure_kind uw_runCallback(uw_context ctx, void (*callback)(uw_context)) {
   int r = setjmp(ctx->jmp_buf);
 
-  if (ctx->app->db_begin(ctx))
-    uw_error(ctx, BOUNDED_RETRY, "Error running SQL BEGIN");
-
   if (r == 0) {
+    if (ctx->app->db_begin(ctx))
+      uw_error(ctx, BOUNDED_RETRY, "Error running SQL BEGIN");
+
     callback(ctx);
-    uw_commit(ctx);
   }
-  else
-    uw_rollback(ctx, 0);
 
   return r;
 }