Mercurial > urweb
comparison 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 |
comparison
equal
deleted
inserted
replaced
1417:d0786ff9bb22 | 1418:22674ac8ebe6 |
---|---|
3682 } | 3682 } |
3683 | 3683 |
3684 failure_kind uw_runCallback(uw_context ctx, void (*callback)(uw_context)) { | 3684 failure_kind uw_runCallback(uw_context ctx, void (*callback)(uw_context)) { |
3685 int r = setjmp(ctx->jmp_buf); | 3685 int r = setjmp(ctx->jmp_buf); |
3686 | 3686 |
3687 if (ctx->app->db_begin(ctx)) | |
3688 uw_error(ctx, BOUNDED_RETRY, "Error running SQL BEGIN"); | |
3689 | |
3690 if (r == 0) { | 3687 if (r == 0) { |
3688 if (ctx->app->db_begin(ctx)) | |
3689 uw_error(ctx, BOUNDED_RETRY, "Error running SQL BEGIN"); | |
3690 | |
3691 callback(ctx); | 3691 callback(ctx); |
3692 uw_commit(ctx); | 3692 } |
3693 } | |
3694 else | |
3695 uw_rollback(ctx, 0); | |
3696 | 3693 |
3697 return r; | 3694 return r; |
3698 } | 3695 } |
3699 | 3696 |
3700 uw_Basis_string uw_Basis_crypt(uw_context ctx, uw_Basis_string key, uw_Basis_string salt) { | 3697 uw_Basis_string uw_Basis_crypt(uw_context ctx, uw_Basis_string key, uw_Basis_string salt) { |