changeset 1774:27fdd78bd2f5

Avoid redundant rollbacks
author Adam Chlipala <adam@chlipala.net>
date Sat, 02 Jun 2012 10:54:49 -0400
parents b5f5e8d439c7
children 6bc2a8cb3a67
files src/c/request.c
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/c/request.c	Sat May 26 09:16:14 2012 -0400
+++ b/src/c/request.c	Sat Jun 02 10:54:49 2012 -0400
@@ -503,6 +503,8 @@
           uw_write(ctx, uw_error_message(ctx));
           uw_write(ctx, "\n</body></html>");
         
+          try_rollback(ctx, 0, logger_data, log_error);
+
           return FAILED;
         }
       } else
@@ -515,8 +517,6 @@
       else {
         log_error(logger_data, "Fatal error (out of retries): %s\n", uw_error_message(ctx));
 
-        try_rollback(ctx, 0, logger_data, log_error);
-
         if (!had_error && uw_get_app(ctx)->on_error) {
           had_error = 1;
           strcpy(errmsg, uw_error_message(ctx));
@@ -528,6 +528,8 @@
           uw_write(ctx, uw_error_message(ctx));
           uw_write(ctx, "\n");
           
+          try_rollback(ctx, 0, logger_data, log_error);
+
           return FAILED;
         }
       }
@@ -536,8 +538,6 @@
     else if (fk == FATAL) {
       log_error(logger_data, "Fatal error: %s\n", uw_error_message(ctx));
 
-      try_rollback(ctx, 0, logger_data, log_error);
-
       if (uw_get_app(ctx)->on_error && !had_error) {
         had_error = 1;
         strcpy(errmsg, uw_error_message(ctx));
@@ -550,13 +550,13 @@
         uw_write(ctx, uw_error_message(ctx));
         uw_write(ctx, "\n</body></html>");
 
+        try_rollback(ctx, 0, logger_data, log_error);
+
         return FAILED;
       }
     } else {
       log_error(logger_data, "Unknown uw_handle return code!\n");
 
-      try_rollback(ctx, 0, logger_data, log_error);
-
       if (uw_get_app(ctx)->on_error && !had_error) {
         had_error = 1;
         strcpy(errmsg, "Unknown uw_handle return code");
@@ -566,6 +566,8 @@
         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;
       }
     }