Mercurial > urweb
comparison src/c/request.c @ 2030:6add6d00ef5f
Call try_rollback before resetting the context
This will allow FFI cleanup handlers to complete.
author | Sergey Mironov <grrwlf@gmail.com> |
---|---|
date | Sun, 15 Jun 2014 21:13:12 +0000 |
parents | bcda3ae88677 |
children | 83bdb52962c9 |
comparison
equal
deleted
inserted
replaced
2029:dfa35ca83d92 | 2030:6add6d00ef5f |
---|---|
501 | 501 |
502 if (uw_get_app(ctx)->on_error) { | 502 if (uw_get_app(ctx)->on_error) { |
503 had_error = 1; | 503 had_error = 1; |
504 strcpy(errmsg, uw_error_message(ctx)); | 504 strcpy(errmsg, uw_error_message(ctx)); |
505 } else { | 505 } else { |
506 try_rollback(ctx, 0, logger_data, log_error); | |
507 | |
506 uw_write_header(ctx, "Content-type: text/html\r\n"); | 508 uw_write_header(ctx, "Content-type: text/html\r\n"); |
507 uw_write(ctx, "<html><head><title>Fatal Error</title></head><body>"); | 509 uw_write(ctx, "<html><head><title>Fatal Error</title></head><body>"); |
508 uw_write(ctx, "Fatal error: "); | 510 uw_write(ctx, "Fatal error: "); |
509 uw_write(ctx, uw_error_message(ctx)); | 511 uw_write(ctx, uw_error_message(ctx)); |
510 uw_write(ctx, "\n</body></html>"); | 512 uw_write(ctx, "\n</body></html>"); |
511 | 513 |
512 try_rollback(ctx, 0, logger_data, log_error); | |
513 | |
514 return FAILED; | 514 return FAILED; |
515 } | 515 } |
516 } else | 516 } else |
517 return had_error ? FAILED : SERVED; | 517 return had_error ? FAILED : SERVED; |
518 } else if (fk == BOUNDED_RETRY) { | 518 } else if (fk == BOUNDED_RETRY) { |
525 | 525 |
526 if (!had_error && uw_get_app(ctx)->on_error) { | 526 if (!had_error && uw_get_app(ctx)->on_error) { |
527 had_error = 1; | 527 had_error = 1; |
528 strcpy(errmsg, uw_error_message(ctx)); | 528 strcpy(errmsg, uw_error_message(ctx)); |
529 } else { | 529 } else { |
530 try_rollback(ctx, 0, logger_data, log_error); | |
531 | |
530 uw_reset_keep_error_message(ctx); | 532 uw_reset_keep_error_message(ctx); |
531 on_failure(ctx); | 533 on_failure(ctx); |
532 uw_write_header(ctx, "Content-type: text/plain\r\n"); | 534 uw_write_header(ctx, "Content-type: text/plain\r\n"); |
533 uw_write(ctx, "Fatal error (out of retries): "); | 535 uw_write(ctx, "Fatal error (out of retries): "); |
534 uw_write(ctx, uw_error_message(ctx)); | 536 uw_write(ctx, uw_error_message(ctx)); |
535 uw_write(ctx, "\n"); | 537 uw_write(ctx, "\n"); |
536 | |
537 try_rollback(ctx, 0, logger_data, log_error); | |
538 | 538 |
539 return FAILED; | 539 return FAILED; |
540 } | 540 } |
541 } | 541 } |
542 } else if (fk == UNLIMITED_RETRY) | 542 } else if (fk == UNLIMITED_RETRY) |
546 | 546 |
547 if (uw_get_app(ctx)->on_error && !had_error) { | 547 if (uw_get_app(ctx)->on_error && !had_error) { |
548 had_error = 1; | 548 had_error = 1; |
549 strcpy(errmsg, uw_error_message(ctx)); | 549 strcpy(errmsg, uw_error_message(ctx)); |
550 } else { | 550 } else { |
551 try_rollback(ctx, 0, logger_data, log_error); | |
552 | |
551 uw_reset_keep_error_message(ctx); | 553 uw_reset_keep_error_message(ctx); |
552 on_failure(ctx); | 554 on_failure(ctx); |
553 uw_write_header(ctx, "Content-type: text/html\r\n"); | 555 uw_write_header(ctx, "Content-type: text/html\r\n"); |
554 uw_write(ctx, "<html><head><title>Fatal Error</title></head><body>"); | 556 uw_write(ctx, "<html><head><title>Fatal Error</title></head><body>"); |
555 uw_write(ctx, "Fatal error: "); | 557 uw_write(ctx, "Fatal error: "); |
556 uw_write(ctx, uw_error_message(ctx)); | 558 uw_write(ctx, uw_error_message(ctx)); |
557 uw_write(ctx, "\n</body></html>"); | 559 uw_write(ctx, "\n</body></html>"); |
558 | 560 |
559 try_rollback(ctx, 0, logger_data, log_error); | |
560 | |
561 return FAILED; | 561 return FAILED; |
562 } | 562 } |
563 } else { | 563 } else { |
564 log_error(logger_data, "Unknown uw_handle return code!\n"); | 564 log_error(logger_data, "Unknown uw_handle return code!\n"); |
565 | 565 |
566 if (uw_get_app(ctx)->on_error && !had_error) { | 566 if (uw_get_app(ctx)->on_error && !had_error) { |
567 had_error = 1; | 567 had_error = 1; |
568 strcpy(errmsg, "Unknown uw_handle return code"); | 568 strcpy(errmsg, "Unknown uw_handle return code"); |
569 } else { | 569 } else { |
570 try_rollback(ctx, 0, logger_data, log_error); | |
571 | |
570 uw_reset_keep_request(ctx); | 572 uw_reset_keep_request(ctx); |
571 on_failure(ctx); | 573 on_failure(ctx); |
572 uw_write_header(ctx, "Content-type: text/plain\r\n"); | 574 uw_write_header(ctx, "Content-type: text/plain\r\n"); |
573 uw_write(ctx, "Unknown uw_handle return code!\n"); | 575 uw_write(ctx, "Unknown uw_handle return code!\n"); |
574 | 576 |
575 try_rollback(ctx, 0, logger_data, log_error); | |
576 | |
577 return FAILED; | 577 return FAILED; |
578 } | 578 } |
579 } | 579 } |
580 | 580 |
581 if (try_rollback(ctx, 1, logger_data, log_error)) | 581 if (try_rollback(ctx, 1, logger_data, log_error)) |