Mercurial > urweb
comparison 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 |
comparison
equal
deleted
inserted
replaced
1103:2f42c61b8d0a | 1104:72670131dace |
---|---|
287 } | 287 } |
288 | 288 |
289 | 289 |
290 // Global entry points | 290 // Global entry points |
291 | 291 |
292 extern void uw_init_crypto(); | |
293 | |
292 void uw_global_init() { | 294 void uw_global_init() { |
293 srand(time(NULL) ^ getpid()); | 295 srand(time(NULL) ^ getpid()); |
294 | 296 |
295 clients = malloc(0); | 297 clients = malloc(0); |
298 | |
299 uw_init_crypto(); | |
296 } | 300 } |
297 | 301 |
298 void uw_app_init(uw_app *app) { | 302 void uw_app_init(uw_app *app) { |
299 app->client_init(); | 303 app->client_init(); |
300 } | 304 } |
418 ctx->cleanup_front = ctx->cleanup_back = ctx->cleanup = malloc(0); | 422 ctx->cleanup_front = ctx->cleanup_back = ctx->cleanup = malloc(0); |
419 | 423 |
420 ctx->script_header = ""; | 424 ctx->script_header = ""; |
421 ctx->needs_push = 0; | 425 ctx->needs_push = 0; |
422 ctx->needs_sig = 0; | 426 ctx->needs_sig = 0; |
423 | 427 |
424 ctx->error_message[0] = 0; | 428 ctx->error_message[0] = 0; |
425 | 429 |
426 ctx->source_count = 0; | 430 ctx->source_count = 0; |
427 | 431 |
428 ctx->n_deltas = ctx->used_deltas = 0; | 432 ctx->n_deltas = ctx->used_deltas = 0; |
2764 | 2768 |
2765 return uw_unit_v; | 2769 return uw_unit_v; |
2766 } | 2770 } |
2767 | 2771 |
2768 void uw_commit(uw_context ctx) { | 2772 void uw_commit(uw_context ctx) { |
2769 unsigned i; | 2773 int i; |
2770 | 2774 |
2771 for (i = 0; i < ctx->used_transactionals; ++i) | 2775 for (i = ctx->used_transactionals-1; i >= 0; --i) |
2772 if (ctx->transactionals[i].rollback != NULL) | 2776 if (ctx->transactionals[i].rollback != NULL) |
2773 if (ctx->transactionals[i].commit) | 2777 if (ctx->transactionals[i].commit) |
2774 ctx->transactionals[i].commit(ctx->transactionals[i].data); | 2778 ctx->transactionals[i].commit(ctx->transactionals[i].data); |
2775 | 2779 |
2776 for (i = 0; i < ctx->used_transactionals; ++i) | 2780 for (i = ctx->used_transactionals-1; i >= 0; --i) |
2777 if (ctx->transactionals[i].rollback == NULL) | 2781 if (ctx->transactionals[i].rollback == NULL) |
2778 if (ctx->transactionals[i].commit) | 2782 if (ctx->transactionals[i].commit) |
2779 ctx->transactionals[i].commit(ctx->transactionals[i].data); | 2783 ctx->transactionals[i].commit(ctx->transactionals[i].data); |
2780 | 2784 |
2781 if (ctx->app->db_commit(ctx)) | 2785 if (ctx->app->db_commit(ctx)) |
2791 } | 2795 } |
2792 | 2796 |
2793 if (ctx->client) | 2797 if (ctx->client) |
2794 release_client(ctx->client); | 2798 release_client(ctx->client); |
2795 | 2799 |
2796 for (i = 0; i < ctx->used_transactionals; ++i) | 2800 for (i = ctx->used_transactionals-1; i >= 0; --i) |
2797 if (ctx->transactionals[i].free) | 2801 if (ctx->transactionals[i].free) |
2798 ctx->transactionals[i].free(ctx->transactionals[i].data); | 2802 ctx->transactionals[i].free(ctx->transactionals[i].data); |
2799 | 2803 |
2800 // Splice script data into appropriate part of page | 2804 // Splice script data into appropriate part of page |
2801 if (ctx->returning_indirectly || ctx->script_header[0] == 0) { | 2805 if (ctx->returning_indirectly || ctx->script_header[0] == 0) { |
2830 } | 2834 } |
2831 } | 2835 } |
2832 } | 2836 } |
2833 | 2837 |
2834 int uw_rollback(uw_context ctx) { | 2838 int uw_rollback(uw_context ctx) { |
2835 size_t i; | 2839 int i; |
2836 cleanup *cl; | 2840 cleanup *cl; |
2837 | 2841 |
2838 if (ctx->client) | 2842 if (ctx->client) |
2839 release_client(ctx->client); | 2843 release_client(ctx->client); |
2840 | 2844 |
2841 for (cl = ctx->cleanup; cl < ctx->cleanup_front; ++cl) | 2845 for (cl = ctx->cleanup; cl < ctx->cleanup_front; ++cl) |
2842 cl->func(cl->arg); | 2846 cl->func(cl->arg); |
2843 | 2847 |
2844 ctx->cleanup_front = ctx->cleanup; | 2848 ctx->cleanup_front = ctx->cleanup; |
2845 | 2849 |
2846 for (i = 0; i < ctx->used_transactionals; ++i) | 2850 for (i = ctx->used_transactionals-1; i >= 0; --i) |
2847 if (ctx->transactionals[i].rollback != NULL) | 2851 if (ctx->transactionals[i].rollback != NULL) |
2848 ctx->transactionals[i].rollback(ctx->transactionals[i].data); | 2852 ctx->transactionals[i].rollback(ctx->transactionals[i].data); |
2849 | 2853 |
2850 for (i = 0; i < ctx->used_transactionals; ++i) | 2854 for (i = ctx->used_transactionals-1; i >= 0; --i) |
2851 if (ctx->transactionals[i].free) | 2855 if (ctx->transactionals[i].free) |
2852 ctx->transactionals[i].free(ctx->transactionals[i].data); | 2856 ctx->transactionals[i].free(ctx->transactionals[i].data); |
2853 | 2857 |
2854 return ctx->app->db_rollback(ctx); | 2858 return ctx->app->db_rollback(ctx); |
2855 } | 2859 } |