Welcome! Log In Create A New Profile

Advanced

[PATCH] RFC: ngx_http_upstream_process_upgraded: Allocate buffers also for data from upstream

Thomas Glanzmann
March 15, 2014 06:14PM
While using the ugprade funcationality of nginx to tunnel propiertary
HTTP commands I noticed that data were only passing through from
upstream to downstream but not the other way around. The reason for that
was that no receive buffers for downstream were allocated. Normally the
receiver buffers for upstream are allocated in
ngx_http_upstream_process_header. In my case they were not because I
upgrade the connection before exchanging any data. Maybe you consider
this for upstream.
---
src/http/ngx_http_upstream.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index cf9ca0d..5ff1f2b 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2644,20 +2644,20 @@ ngx_http_upstream_process_upgraded(ngx_http_request_t *r,
b->end = b->last;
do_write = 1;
}
+ }

+ if (b->start == NULL) {
+ b->start = ngx_palloc(r->pool, u->conf->buffer_size);
if (b->start == NULL) {
- b->start = ngx_palloc(r->pool, u->conf->buffer_size);
- if (b->start == NULL) {
- ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
- return;
- }
-
- b->pos = b->start;
- b->last = b->start;
- b->end = b->start + u->conf->buffer_size;
- b->temporary = 1;
- b->tag = u->output.tag;
+ ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
+ return;
}
+
+ b->pos = b->start;
+ b->last = b->start;
+ b->end = b->start + u->conf->buffer_size;
+ b->temporary = 1;
+ b->tag = u->output.tag;
}

for ( ;; ) {
--
1.7.10.4

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

[PATCH] RFC: ngx_http_upstream_process_upgraded: Allocate buffers also for data from upstream

Thomas Glanzmann March 15, 2014 06:14PM

Re: [PATCH] RFC: ngx_http_upstream_process_upgraded: Allocate buffers also for data from upstream

Maxim Dounin March 16, 2014 10:40PM

Re: [PATCH] RFC: ngx_http_upstream_process_upgraded: Allocate buffers also for data from upstream

Thomas Glanzmann March 17, 2014 04:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 129
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready