diff src/c/urweb.c @ 1104:72670131dace

Basis.serialize; separate file for mhash; run transactional finishers in reverse order; set needs_sig properly
author Adam Chlipala <adamc@hcoop.net>
date Thu, 31 Dec 2009 11:41:57 -0500
parents db52c32dbe42
children a5c160636832
line wrap: on
line diff
--- a/src/c/urweb.c	Wed Dec 30 09:52:18 2009 -0500
+++ b/src/c/urweb.c	Thu Dec 31 11:41:57 2009 -0500
@@ -289,10 +289,14 @@
 
 // Global entry points
 
+extern void uw_init_crypto();
+
 void uw_global_init() {
   srand(time(NULL) ^ getpid());
 
   clients = malloc(0);
+
+  uw_init_crypto();
 }
 
 void uw_app_init(uw_app *app) {
@@ -420,7 +424,7 @@
   ctx->script_header = "";
   ctx->needs_push = 0;
   ctx->needs_sig = 0;
-  
+
   ctx->error_message[0] = 0;
 
   ctx->source_count = 0;
@@ -2766,14 +2770,14 @@
 }
 
 void uw_commit(uw_context ctx) {
-  unsigned i;
-
-  for (i = 0; i < ctx->used_transactionals; ++i)
+  int i;
+
+  for (i = ctx->used_transactionals-1; i >= 0; --i)
     if (ctx->transactionals[i].rollback != NULL)
       if (ctx->transactionals[i].commit)
         ctx->transactionals[i].commit(ctx->transactionals[i].data);
 
-  for (i = 0; i < ctx->used_transactionals; ++i)
+  for (i = ctx->used_transactionals-1; i >= 0; --i)
     if (ctx->transactionals[i].rollback == NULL)
       if (ctx->transactionals[i].commit)
         ctx->transactionals[i].commit(ctx->transactionals[i].data);
@@ -2793,7 +2797,7 @@
   if (ctx->client)
     release_client(ctx->client);
 
-  for (i = 0; i < ctx->used_transactionals; ++i)
+  for (i = ctx->used_transactionals-1; i >= 0; --i)
     if (ctx->transactionals[i].free)
       ctx->transactionals[i].free(ctx->transactionals[i].data);
 
@@ -2832,7 +2836,7 @@
 }
 
 int uw_rollback(uw_context ctx) {
-  size_t i;
+  int i;
   cleanup *cl;
 
   if (ctx->client)
@@ -2843,11 +2847,11 @@
 
   ctx->cleanup_front = ctx->cleanup;
 
-  for (i = 0; i < ctx->used_transactionals; ++i)
+  for (i = ctx->used_transactionals-1; i >= 0; --i)
     if (ctx->transactionals[i].rollback != NULL)
       ctx->transactionals[i].rollback(ctx->transactionals[i].data);
 
-  for (i = 0; i < ctx->used_transactionals; ++i)
+  for (i = ctx->used_transactionals-1; i >= 0; --i)
     if (ctx->transactionals[i].free)
       ctx->transactionals[i].free(ctx->transactionals[i].data);