diff src/c/driver.c @ 671:729e65db2e2f

Transactionalize channel operations
author Adam Chlipala <adamc@hcoop.net>
date Tue, 24 Mar 2009 14:44:45 -0400
parents b0c1a46b1f15
children 5bbb542243e8
line wrap: on
line diff
--- a/src/c/driver.c	Sun Mar 22 16:03:45 2009 -0400
+++ b/src/c/driver.c	Tue Mar 24 14:44:45 2009 -0400
@@ -53,12 +53,8 @@
 
 #define MAX_RETRIES 5
 
-int uw_db_begin(uw_context);
-int uw_db_commit(uw_context);
-int uw_db_rollback(uw_context);
-
 static int try_rollback(uw_context ctx) {
-  int r = uw_db_rollback(ctx);
+  int r = uw_rollback(ctx);
 
   if (r) {
     printf("Error running SQL ROLLBACK\n");
@@ -206,36 +202,12 @@
         printf("Serving URI %s....\n", path);
 
         while (1) {
-          if (uw_db_begin(ctx)) {
-            printf("Error running SQL BEGIN\n");
-            if (retries_left)
-              --retries_left;
-            else {
-              fk = FATAL;
-              uw_reset(ctx);
-              uw_write_header(ctx, "HTTP/1.1 500 Internal Server Error\n\r");
-              uw_write_header(ctx, "Content-type: text/plain\r\n\r\n");
-              uw_write(ctx, "Error running SQL BEGIN\n");
-
-              break;
-            }
-          }
-
           uw_write_header(ctx, "HTTP/1.1 200 OK\r\n");
 
           strcpy(path_copy, path);
           fk = uw_begin(ctx, path_copy);
           if (fk == SUCCESS) {
-            if (uw_db_commit(ctx)) {
-              fk = FATAL;
-
-              printf("Error running SQL COMMIT\n");
-              uw_reset(ctx);
-              uw_write_header(ctx, "HTTP/1.1 500 Internal Server Error\n\r");
-              uw_write_header(ctx, "Content-type: text/plain\r\n");
-              uw_write(ctx, "Error running SQL COMMIT\n");
-            }
-
+            uw_commit(ctx);
             break;
           } else if (fk == BOUNDED_RETRY) {
             if (retries_left) {