comparison src/c/request.c @ 1774:27fdd78bd2f5

Avoid redundant rollbacks
author Adam Chlipala <adam@chlipala.net>
date Sat, 02 Jun 2012 10:54:49 -0400
parents 4d0b80dd4c37
children 69daa6d70299
comparison
equal deleted inserted replaced
1773:b5f5e8d439c7 1774:27fdd78bd2f5
501 uw_write(ctx, "<html><head><title>Fatal Error</title></head><body>"); 501 uw_write(ctx, "<html><head><title>Fatal Error</title></head><body>");
502 uw_write(ctx, "Fatal error: "); 502 uw_write(ctx, "Fatal error: ");
503 uw_write(ctx, uw_error_message(ctx)); 503 uw_write(ctx, uw_error_message(ctx));
504 uw_write(ctx, "\n</body></html>"); 504 uw_write(ctx, "\n</body></html>");
505 505
506 try_rollback(ctx, 0, logger_data, log_error);
507
506 return FAILED; 508 return FAILED;
507 } 509 }
508 } else 510 } else
509 return had_error ? FAILED : SERVED; 511 return had_error ? FAILED : SERVED;
510 } else if (fk == BOUNDED_RETRY) { 512 } else if (fk == BOUNDED_RETRY) {
512 log_debug(logger_data, "Error triggers bounded retry: %s\n", uw_error_message(ctx)); 514 log_debug(logger_data, "Error triggers bounded retry: %s\n", uw_error_message(ctx));
513 --retries_left; 515 --retries_left;
514 } 516 }
515 else { 517 else {
516 log_error(logger_data, "Fatal error (out of retries): %s\n", uw_error_message(ctx)); 518 log_error(logger_data, "Fatal error (out of retries): %s\n", uw_error_message(ctx));
517
518 try_rollback(ctx, 0, logger_data, log_error);
519 519
520 if (!had_error && uw_get_app(ctx)->on_error) { 520 if (!had_error && uw_get_app(ctx)->on_error) {
521 had_error = 1; 521 had_error = 1;
522 strcpy(errmsg, uw_error_message(ctx)); 522 strcpy(errmsg, uw_error_message(ctx));
523 } else { 523 } else {
526 uw_write_header(ctx, "Content-type: text/plain\r\n"); 526 uw_write_header(ctx, "Content-type: text/plain\r\n");
527 uw_write(ctx, "Fatal error (out of retries): "); 527 uw_write(ctx, "Fatal error (out of retries): ");
528 uw_write(ctx, uw_error_message(ctx)); 528 uw_write(ctx, uw_error_message(ctx));
529 uw_write(ctx, "\n"); 529 uw_write(ctx, "\n");
530 530
531 try_rollback(ctx, 0, logger_data, log_error);
532
531 return FAILED; 533 return FAILED;
532 } 534 }
533 } 535 }
534 } else if (fk == UNLIMITED_RETRY) 536 } else if (fk == UNLIMITED_RETRY)
535 log_debug(logger_data, "Error triggers unlimited retry: %s\n", uw_error_message(ctx)); 537 log_debug(logger_data, "Error triggers unlimited retry: %s\n", uw_error_message(ctx));
536 else if (fk == FATAL) { 538 else if (fk == FATAL) {
537 log_error(logger_data, "Fatal error: %s\n", uw_error_message(ctx)); 539 log_error(logger_data, "Fatal error: %s\n", uw_error_message(ctx));
538
539 try_rollback(ctx, 0, logger_data, log_error);
540 540
541 if (uw_get_app(ctx)->on_error && !had_error) { 541 if (uw_get_app(ctx)->on_error && !had_error) {
542 had_error = 1; 542 had_error = 1;
543 strcpy(errmsg, uw_error_message(ctx)); 543 strcpy(errmsg, uw_error_message(ctx));
544 } else { 544 } else {
548 uw_write(ctx, "<html><head><title>Fatal Error</title></head><body>"); 548 uw_write(ctx, "<html><head><title>Fatal Error</title></head><body>");
549 uw_write(ctx, "Fatal error: "); 549 uw_write(ctx, "Fatal error: ");
550 uw_write(ctx, uw_error_message(ctx)); 550 uw_write(ctx, uw_error_message(ctx));
551 uw_write(ctx, "\n</body></html>"); 551 uw_write(ctx, "\n</body></html>");
552 552
553 try_rollback(ctx, 0, logger_data, log_error);
554
553 return FAILED; 555 return FAILED;
554 } 556 }
555 } else { 557 } else {
556 log_error(logger_data, "Unknown uw_handle return code!\n"); 558 log_error(logger_data, "Unknown uw_handle return code!\n");
557
558 try_rollback(ctx, 0, logger_data, log_error);
559 559
560 if (uw_get_app(ctx)->on_error && !had_error) { 560 if (uw_get_app(ctx)->on_error && !had_error) {
561 had_error = 1; 561 had_error = 1;
562 strcpy(errmsg, "Unknown uw_handle return code"); 562 strcpy(errmsg, "Unknown uw_handle return code");
563 } else { 563 } else {
564 uw_reset_keep_request(ctx); 564 uw_reset_keep_request(ctx);
565 on_failure(ctx); 565 on_failure(ctx);
566 uw_write_header(ctx, "Content-type: text/plain\r\n"); 566 uw_write_header(ctx, "Content-type: text/plain\r\n");
567 uw_write(ctx, "Unknown uw_handle return code!\n"); 567 uw_write(ctx, "Unknown uw_handle return code!\n");
568 568
569 try_rollback(ctx, 0, logger_data, log_error);
570
569 return FAILED; 571 return FAILED;
570 } 572 }
571 } 573 }
572 574
573 if (try_rollback(ctx, 1, logger_data, log_error)) 575 if (try_rollback(ctx, 1, logger_data, log_error))