Changeset d1eed0a31060e85817e7ca2188361aafcf6f115e
- Timestamp:
- 04/06/10 21:47:59
(3 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1270590479 +0000
- git-parent:
[fddf7172a39575dd9460f878ba73e3b42e8f8154]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1270590479 +0000
- Message:
loggers for http and critical but if pipelined payload, we weren't shortening the input buffer once we dissected out the payload post-headers
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rfddf717 |
rd1eed0a |
|
| 46 | 46 | #define HEADER_EXPECT "expect" |
|---|
| 47 | 47 | |
|---|
| | 48 | static noit_log_stream_t http_debug = NULL; |
|---|
| | 49 | static noit_log_stream_t http_io = NULL; |
|---|
| | 50 | static noit_log_stream_t http_access = NULL; |
|---|
| | 51 | |
|---|
| 48 | 52 | #define CTX_ADD_HEADER(a,b) \ |
|---|
| 49 | 53 | noit_hash_replace(&ctx->res.headers, \ |
|---|
| … | … | |
| 238 | 242 | return -1; |
|---|
| 239 | 243 | } |
|---|
| | 244 | noitL(http_io, " http_write(%d) => %d [\n%.*s\n]\n", ctx->conn.e->fd, |
|---|
| | 245 | len, len, b->buff + b->start + ctx->res.output_raw_offset); |
|---|
| 240 | 246 | ctx->res.output_raw_offset += len; |
|---|
| 241 | 247 | tlen += len; |
|---|
| … | … | |
| 284 | 290 | match: |
|---|
| 285 | 291 | req->current_request_chain = req->first_input; |
|---|
| 286 | | noitL(noit_debug, " noit_http_request_finalize : match(%d in %d)\n", |
|---|
| | 292 | noitL(http_debug, " noit_http_request_finalize : match(%d in %d)\n", |
|---|
| 287 | 293 | (int)(req->current_offset - req->current_input->start), |
|---|
| 288 | 294 | (int)req->current_input->size); |
|---|
| … | … | |
| 291 | 297 | /* There are left-overs */ |
|---|
| 292 | 298 | int lsize = req->current_input->size - req->current_offset; |
|---|
| 293 | | noitL(noit_debug, " noit_http_request_finalize -- leftovers: %d\n", lsize); |
|---|
| | 299 | noitL(http_debug, " noit_http_request_finalize -- leftovers: %d\n", lsize); |
|---|
| 294 | 300 | req->first_input = bchain_alloc(lsize); |
|---|
| 295 | 301 | req->first_input->prev = NULL; |
|---|
| … | … | |
| 300 | 306 | req->current_input->buff + req->current_offset, |
|---|
| 301 | 307 | req->first_input->size); |
|---|
| | 308 | req->current_input->size -= lsize; |
|---|
| 302 | 309 | if(req->last_input == req->current_input) |
|---|
| 303 | 310 | req->last_input = req->first_input; |
|---|
| … | … | |
| 491 | 498 | in->allocd - in->size - in->start, |
|---|
| 492 | 499 | &mask, ctx->conn.e); |
|---|
| 493 | | noitL(noit_debug, " noit_http -> read(%d) = %d\n", ctx->conn.e->fd, len); |
|---|
| | 500 | noitL(http_debug, " noit_http -> read(%d) = %d\n", ctx->conn.e->fd, len); |
|---|
| | 501 | noitL(http_io, " noit_http:read(%d) => %d [\n%.*s\n]\n", ctx->conn.e->fd, len, len, in->buff + in->start + in->size); |
|---|
| 494 | 502 | if(len == -1 && errno == EAGAIN) return mask; |
|---|
| 495 | 503 | if(len <= 0) goto full_error; |
|---|
| … | … | |
| 562 | 570 | /* We attempt to consume from the first_input */ |
|---|
| 563 | 571 | struct bchain *in, *tofree; |
|---|
| 564 | | noitL(noit_debug, " ... noit_http_session_req_consume(%d) %d of %d\n", |
|---|
| | 572 | noitL(http_debug, " ... noit_http_session_req_consume(%d) %d of %d\n", |
|---|
| 565 | 573 | ctx->conn.e->fd, (int)len, |
|---|
| 566 | 574 | (int)(ctx->req.content_length - ctx->req.content_length_read)); |
|---|
| … | … | |
| 574 | 582 | bytes_read += partial_len; |
|---|
| 575 | 583 | ctx->req.content_length_read += partial_len; |
|---|
| 576 | | noitL(noit_debug, " ... filling %d bytes (read through %d/%d)\n", |
|---|
| | 584 | noitL(http_debug, " ... filling %d bytes (read through %d/%d)\n", |
|---|
| 577 | 585 | (int)bytes_read, (int)ctx->req.content_length_read, |
|---|
| 578 | 586 | (int)ctx->req.content_length); |
|---|
| … | … | |
| 586 | 594 | if(in == NULL) { |
|---|
| 587 | 595 | ctx->req.last_input = NULL; |
|---|
| 588 | | noitL(noit_debug, " ... noit_http_session_req_consume = %d\n", |
|---|
| | 596 | noitL(http_debug, " ... noit_http_session_req_consume = %d\n", |
|---|
| 589 | 597 | (int)bytes_read); |
|---|
| 590 | 598 | return bytes_read; |
|---|
| … | … | |
| 607 | 615 | in->allocd - in->size - in->start, |
|---|
| 608 | 616 | mask, ctx->conn.e); |
|---|
| 609 | | noitL(noit_debug, " noit_http -> read(%d) = %d\n", ctx->conn.e->fd, rlen); |
|---|
| | 617 | noitL(http_debug, " noit_http -> read(%d) = %d\n", ctx->conn.e->fd, rlen); |
|---|
| | 618 | noitL(http_io, " noit_http:read(%d) => %d [\n%.*s\n]\n", ctx->conn.e->fd, rlen, rlen, in->buff + in->start + in->size); |
|---|
| 610 | 619 | if(rlen == -1 && errno == EAGAIN) { |
|---|
| 611 | 620 | /* We'd block to read more, but we have data, |
|---|
| … | … | |
| 613 | 622 | if(ctx->req.first_input->size) break; |
|---|
| 614 | 623 | /* We've got nothing... */ |
|---|
| 615 | | noitL(noit_debug, " ... noit_http_session_req_consume = -1 (EAGAIN)\n"); |
|---|
| | 624 | noitL(http_debug, " ... noit_http_session_req_consume = -1 (EAGAIN)\n"); |
|---|
| 616 | 625 | return -1; |
|---|
| 617 | 626 | } |
|---|
| 618 | 627 | if(rlen <= 0) { |
|---|
| 619 | | noitL(noit_debug, " ... noit_http_session_req_consume = -1 (error)\n"); |
|---|
| | 628 | noitL(http_debug, " ... noit_http_session_req_consume = -1 (error)\n"); |
|---|
| 620 | 629 | return -1; |
|---|
| 621 | 630 | } |
|---|
| … | … | |
| 641 | 650 | * noted that in noit_http_request_release. |
|---|
| 642 | 651 | */ |
|---|
| 643 | | noitL(noit_debug, " -> noit_http_session_drive(%d) [%x]\n", e->fd, origmask); |
|---|
| | 652 | noitL(http_debug, " -> noit_http_session_drive(%d) [%x]\n", e->fd, origmask); |
|---|
| 644 | 653 | while(ctx->drainage > 0) { |
|---|
| 645 | 654 | int len; |
|---|
| 646 | | noitL(noit_debug, " ... draining last request(%d)\n", e->fd); |
|---|
| | 655 | noitL(http_debug, " ... draining last request(%d)\n", e->fd); |
|---|
| 647 | 656 | len = noit_http_session_req_consume(ctx, NULL, ctx->drainage, &mask); |
|---|
| 648 | 657 | if(len == -1 && errno == EAGAIN) { |
|---|
| 649 | | noitL(noit_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, mask); |
|---|
| | 658 | noitL(http_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, mask); |
|---|
| 650 | 659 | return mask; |
|---|
| 651 | 660 | } |
|---|
| … | … | |
| 657 | 666 | if(ctx->req.complete != noit_true) { |
|---|
| 658 | 667 | int maybe_write_mask; |
|---|
| 659 | | noitL(noit_debug, " -> noit_http_complete_request(%d)\n", e->fd); |
|---|
| | 668 | noitL(http_debug, " -> noit_http_complete_request(%d)\n", e->fd); |
|---|
| 660 | 669 | mask = noit_http_complete_request(ctx, origmask); |
|---|
| 661 | | noitL(noit_debug, " <- noit_http_complete_request(%d) = %d\n", |
|---|
| | 670 | noitL(http_debug, " <- noit_http_complete_request(%d) = %d\n", |
|---|
| 662 | 671 | e->fd, mask); |
|---|
| 663 | 672 | _http_perform_write(ctx, &maybe_write_mask); |
|---|
| 664 | 673 | if(ctx->conn.e == NULL) goto release; |
|---|
| 665 | 674 | if(ctx->req.complete != noit_true) { |
|---|
| 666 | | noitL(noit_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, |
|---|
| | 675 | noitL(http_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, |
|---|
| 667 | 676 | mask|maybe_write_mask); |
|---|
| 668 | 677 | return mask | maybe_write_mask; |
|---|
| 669 | 678 | } |
|---|
| 670 | | noitL(noit_debug, "HTTP start request (%s)\n", ctx->req.uri_str); |
|---|
| | 679 | noitL(http_access, "HTTP start request (%s)\n", ctx->req.uri_str); |
|---|
| 671 | 680 | } |
|---|
| 672 | 681 | |
|---|
| 673 | 682 | /* only dispatch if the response is not complete */ |
|---|
| 674 | 683 | if(ctx->res.complete == noit_false) { |
|---|
| 675 | | noitL(noit_debug, " -> dispatch(%d)\n", e->fd); |
|---|
| | 684 | noitL(http_debug, " -> dispatch(%d)\n", e->fd); |
|---|
| 676 | 685 | rv = ctx->dispatcher(ctx); |
|---|
| 677 | | noitL(noit_debug, " <- dispatch(%d) = %d\n", e->fd, rv); |
|---|
| | 686 | noitL(http_debug, " <- dispatch(%d) = %d\n", e->fd, rv); |
|---|
| 678 | 687 | } |
|---|
| 679 | 688 | |
|---|
| … | … | |
| 693 | 702 | if(ctx->req.complete == noit_false) goto next_req; |
|---|
| 694 | 703 | if(ctx->conn.e) { |
|---|
| 695 | | noitL(noit_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, mask|rv); |
|---|
| | 704 | noitL(http_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, mask|rv); |
|---|
| 696 | 705 | return mask | rv; |
|---|
| 697 | 706 | } |
|---|
| 698 | | noitL(noit_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, 0); |
|---|
| | 707 | noitL(http_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, 0); |
|---|
| 699 | 708 | return 0; |
|---|
| 700 | 709 | release: |
|---|
| 701 | 710 | noit_http_ctx_session_release(ctx); |
|---|
| 702 | | noitL(noit_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, 0); |
|---|
| | 711 | noitL(http_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, 0); |
|---|
| 703 | 712 | return 0; |
|---|
| 704 | 713 | } |
|---|
| … | … | |
| 1034 | 1043 | noit_http_response_end(noit_http_session_ctx *ctx) { |
|---|
| 1035 | 1044 | if(ctx->res.output) |
|---|
| 1036 | | noitL(noit_debug, "HTTP finished request (%s)\n", ctx->req.uri_str); |
|---|
| | 1045 | noitL(http_access, "HTTP finished request (%s)\n", ctx->req.uri_str); |
|---|
| 1037 | 1046 | if(!noit_http_response_flush(ctx, noit_true)) return noit_false; |
|---|
| 1038 | 1047 | return noit_true; |
|---|
| … | … | |
| 1064 | 1073 | } |
|---|
| 1065 | 1074 | |
|---|
| | 1075 | void |
|---|
| | 1076 | noit_http_init() { |
|---|
| | 1077 | http_debug = noit_log_stream_find("debug/http"); |
|---|
| | 1078 | http_access = noit_log_stream_find("http/access"); |
|---|
| | 1079 | http_io = noit_log_stream_find("http/io"); |
|---|
| | 1080 | } |
|---|
| rfddf717 |
rd1eed0a |
|
| 180 | 180 | noit_http_response_xml(noit_http_session_ctx *, xmlDocPtr); |
|---|
| 181 | 181 | |
|---|
| | 182 | API_EXPORT(void) |
|---|
| | 183 | noit_http_init(); |
|---|
| 182 | 184 | |
|---|
| 183 | 185 | #endif |
|---|
| r3d36f5a |
rd1eed0a |
|
| 558 | 558 | } |
|---|
| 559 | 559 | void noit_http_rest_init() { |
|---|
| | 560 | noit_http_init(); |
|---|
| 560 | 561 | eventer_name_callback("noit_wire_rest_api/1.0", noit_http_rest_handler); |
|---|
| 561 | 562 | eventer_name_callback("http_rest_api", noit_http_rest_raw_handler); |
|---|