summaryrefslogtreecommitdiff
path: root/src/c/urweb.c
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2010-12-18 15:17:09 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2010-12-18 15:17:09 -0500
commit541a15124e163ce8aff94bf37f24c54085c19884 (patch)
tree3f41e8cb1cc8bb5b84384840ebdf5b296e0c1732 /src/c/urweb.c
parent39cd3aba26129807a15ccc29bb9f71e2537c4551 (diff)
Periodic tasks
Diffstat (limited to 'src/c/urweb.c')
-rw-r--r--src/c/urweb.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c
index 2b54e87c..0356e0fa 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -3492,3 +3492,19 @@ uw_Basis_postBody uw_getPostBody(uw_context ctx) {
else
uw_error(ctx, FATAL, "Asked for POST body when none exists");
}
+
+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) {
+ callback(ctx);
+ uw_commit(ctx);
+ }
+ else
+ uw_rollback(ctx, 0);
+
+ return r;
+}