Mercurial > hg > nginx
comparison src/http/ngx_http_request_body.c @ 7693:f5a2af0e7079
Request body: optimized handling of small chunks.
If there is a previous buffer, copy small chunks into it instead of
allocating additional buffer.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 06 Aug 2020 05:02:57 +0300 |
parents | 0f7f1a509113 |
children | 554c6ae25ffc 532fe796b0e2 |
comparison
equal
deleted
inserted
replaced
7692:0f7f1a509113 | 7693:f5a2af0e7079 |
---|---|
1025 out = NULL; | 1025 out = NULL; |
1026 ll = &out; | 1026 ll = &out; |
1027 | 1027 |
1028 for (cl = in; cl; cl = cl->next) { | 1028 for (cl = in; cl; cl = cl->next) { |
1029 | 1029 |
1030 b = NULL; | |
1031 | |
1030 for ( ;; ) { | 1032 for ( ;; ) { |
1031 | 1033 |
1032 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, r->connection->log, 0, | 1034 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, r->connection->log, 0, |
1033 "http body chunked buf " | 1035 "http body chunked buf " |
1034 "t:%d f:%d %p, pos %p, size: %z file: %O, size: %O", | 1036 "t:%d f:%d %p, pos %p, size: %z file: %O, size: %O", |
1057 rb->chunked->size); | 1059 rb->chunked->size); |
1058 | 1060 |
1059 r->lingering_close = 1; | 1061 r->lingering_close = 1; |
1060 | 1062 |
1061 return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE; | 1063 return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE; |
1064 } | |
1065 | |
1066 if (b | |
1067 && rb->chunked->size <= 128 | |
1068 && cl->buf->last - cl->buf->pos >= rb->chunked->size) | |
1069 { | |
1070 r->headers_in.content_length_n += rb->chunked->size; | |
1071 | |
1072 if (rb->chunked->size < 8) { | |
1073 | |
1074 while (rb->chunked->size) { | |
1075 *b->last++ = *cl->buf->pos++; | |
1076 rb->chunked->size--; | |
1077 } | |
1078 | |
1079 } else { | |
1080 ngx_memmove(b->last, cl->buf->pos, rb->chunked->size); | |
1081 b->last += rb->chunked->size; | |
1082 cl->buf->pos += rb->chunked->size; | |
1083 rb->chunked->size = 0; | |
1084 } | |
1085 | |
1086 continue; | |
1062 } | 1087 } |
1063 | 1088 |
1064 tl = ngx_chain_get_free_buf(r->pool, &rb->free); | 1089 tl = ngx_chain_get_free_buf(r->pool, &rb->free); |
1065 if (tl == NULL) { | 1090 if (tl == NULL) { |
1066 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 1091 return NGX_HTTP_INTERNAL_SERVER_ERROR; |