comparison src/c/urweb.c @ 1083:2eb585274501

Stop skipping Especialization of generated functions; fix Compiler.parseUrp; expose uw_really_write(); allow more NULL arguments to uw_register_transactional()
author Adam Chlipala <adamc@hcoop.net>
date Wed, 23 Dec 2009 12:25:34 -0500
parents 50dd937c4cb9
children 8e240c007442
comparison
equal deleted inserted replaced
1082:4b2f50829af5 1083:2eb585274501
2771 void uw_commit(uw_context ctx) { 2771 void uw_commit(uw_context ctx) {
2772 unsigned i; 2772 unsigned i;
2773 2773
2774 for (i = 0; i < ctx->used_transactionals; ++i) 2774 for (i = 0; i < ctx->used_transactionals; ++i)
2775 if (ctx->transactionals[i].rollback != NULL) 2775 if (ctx->transactionals[i].rollback != NULL)
2776 ctx->transactionals[i].commit(ctx->transactionals[i].data); 2776 if (ctx->transactionals[i].commit)
2777 ctx->transactionals[i].commit(ctx->transactionals[i].data);
2777 2778
2778 for (i = 0; i < ctx->used_transactionals; ++i) 2779 for (i = 0; i < ctx->used_transactionals; ++i)
2779 if (ctx->transactionals[i].rollback == NULL) 2780 if (ctx->transactionals[i].rollback == NULL)
2780 ctx->transactionals[i].commit(ctx->transactionals[i].data); 2781 if (ctx->transactionals[i].commit)
2782 ctx->transactionals[i].commit(ctx->transactionals[i].data);
2781 2783
2782 if (uw_db_commit(ctx)) 2784 if (uw_db_commit(ctx))
2783 uw_error(ctx, FATAL, "Error running SQL COMMIT"); 2785 uw_error(ctx, FATAL, "Error running SQL COMMIT");
2784 2786
2785 for (i = 0; i < ctx->used_deltas; ++i) { 2787 for (i = 0; i < ctx->used_deltas; ++i) {
2793 2795
2794 if (ctx->client) 2796 if (ctx->client)
2795 release_client(ctx->client); 2797 release_client(ctx->client);
2796 2798
2797 for (i = 0; i < ctx->used_transactionals; ++i) 2799 for (i = 0; i < ctx->used_transactionals; ++i)
2798 ctx->transactionals[i].free(ctx->transactionals[i].data); 2800 if (ctx->transactionals[i].free)
2801 ctx->transactionals[i].free(ctx->transactionals[i].data);
2799 2802
2800 // Splice script data into appropriate part of page 2803 // Splice script data into appropriate part of page
2801 if (ctx->returning_indirectly || ctx->script_header[0] == 0) { 2804 if (ctx->returning_indirectly || ctx->script_header[0] == 0) {
2802 char *start = strstr(ctx->page.start, "<sc>"); 2805 char *start = strstr(ctx->page.start, "<sc>");
2803 if (start) { 2806 if (start) {
2853 return uw_db_rollback(ctx); 2856 return uw_db_rollback(ctx);
2854 } 2857 }
2855 2858
2856 void uw_register_transactional(uw_context ctx, void *data, uw_callback commit, uw_callback rollback, 2859 void uw_register_transactional(uw_context ctx, void *data, uw_callback commit, uw_callback rollback,
2857 uw_callback free) { 2860 uw_callback free) {
2858 if (commit == NULL)
2859 uw_error(ctx, FATAL, "uw_register_transactional: NULL commit callback");
2860
2861 if (ctx->used_transactionals >= ctx->n_transactionals) { 2861 if (ctx->used_transactionals >= ctx->n_transactionals) {
2862 ctx->transactionals = realloc(ctx->transactionals, ctx->used_transactionals+1); 2862 ctx->transactionals = realloc(ctx->transactionals, ctx->used_transactionals+1);
2863 ++ctx->n_transactionals; 2863 ++ctx->n_transactionals;
2864 } 2864 }
2865 2865