summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sergey Mironov <grrwlf@gmail.com>2014-06-15 21:13:12 +0000
committerGravatar Sergey Mironov <grrwlf@gmail.com>2014-06-15 21:13:12 +0000
commit0a45f32c63f2d9a3df8c8ea15ea67b8e8c0fef5a (patch)
treec736f5fa666d6e638ea84d897e4c7e742e3603c9
parent9bfceb750b35c2f20d924987807702da42d12709 (diff)
Call try_rollback before resetting the context
This will allow FFI cleanup handlers to complete.
-rw-r--r--src/c/request.c16
-rw-r--r--src/c/urweb.c2
2 files changed, 9 insertions, 9 deletions
diff --git a/src/c/request.c b/src/c/request.c
index 5aee7bbe..f212655f 100644
--- a/src/c/request.c
+++ b/src/c/request.c
@@ -503,14 +503,14 @@ request_result uw_request(uw_request_context rc, uw_context ctx,
had_error = 1;
strcpy(errmsg, uw_error_message(ctx));
} else {
+ try_rollback(ctx, 0, logger_data, log_error);
+
uw_write_header(ctx, "Content-type: text/html\r\n");
uw_write(ctx, "<html><head><title>Fatal Error</title></head><body>");
uw_write(ctx, "Fatal error: ");
uw_write(ctx, uw_error_message(ctx));
uw_write(ctx, "\n</body></html>");
- try_rollback(ctx, 0, logger_data, log_error);
-
return FAILED;
}
} else
@@ -527,14 +527,14 @@ request_result uw_request(uw_request_context rc, uw_context ctx,
had_error = 1;
strcpy(errmsg, uw_error_message(ctx));
} else {
+ try_rollback(ctx, 0, logger_data, log_error);
+
uw_reset_keep_error_message(ctx);
on_failure(ctx);
uw_write_header(ctx, "Content-type: text/plain\r\n");
uw_write(ctx, "Fatal error (out of retries): ");
uw_write(ctx, uw_error_message(ctx));
uw_write(ctx, "\n");
-
- try_rollback(ctx, 0, logger_data, log_error);
return FAILED;
}
@@ -548,6 +548,8 @@ request_result uw_request(uw_request_context rc, uw_context ctx,
had_error = 1;
strcpy(errmsg, uw_error_message(ctx));
} else {
+ try_rollback(ctx, 0, logger_data, log_error);
+
uw_reset_keep_error_message(ctx);
on_failure(ctx);
uw_write_header(ctx, "Content-type: text/html\r\n");
@@ -556,8 +558,6 @@ request_result uw_request(uw_request_context rc, uw_context ctx,
uw_write(ctx, uw_error_message(ctx));
uw_write(ctx, "\n</body></html>");
- try_rollback(ctx, 0, logger_data, log_error);
-
return FAILED;
}
} else {
@@ -567,13 +567,13 @@ request_result uw_request(uw_request_context rc, uw_context ctx,
had_error = 1;
strcpy(errmsg, "Unknown uw_handle return code");
} else {
+ try_rollback(ctx, 0, logger_data, log_error);
+
uw_reset_keep_request(ctx);
on_failure(ctx);
uw_write_header(ctx, "Content-type: text/plain\r\n");
uw_write(ctx, "Unknown uw_handle return code!\n");
- try_rollback(ctx, 0, logger_data, log_error);
-
return FAILED;
}
}
diff --git a/src/c/urweb.c b/src/c/urweb.c
index 020e69d4..7b95d6a9 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -3343,7 +3343,7 @@ int uw_commit(uw_context ctx) {
if (ctx->transactionals[i].free)
ctx->transactionals[i].free(ctx->transactionals[i].data, 1);
- return 1;
+ return 1;
}
for (i = ctx->used_transactionals-1; i >= 0; --i)