Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
116 lines (97 sloc) 3.51 KB
Index: nginx-catap/nginx/src/event/ngx_event_pipe.c
===================================================================
--- nginx-catap.orig/nginx/src/event/ngx_event_pipe.c
+++ nginx-catap/nginx/src/event/ngx_event_pipe.c
@@ -10,7 +10,8 @@
#include <ngx_event_pipe.h>
-static ngx_int_t ngx_event_pipe_read_upstream(ngx_event_pipe_t *p);
+static ngx_int_t ngx_event_pipe_read_upstream(ngx_event_pipe_t *p,
+ ngx_int_t do_flush);
static ngx_int_t ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p);
static ngx_int_t ngx_event_pipe_write_chain_to_temp_file(ngx_event_pipe_t *p);
@@ -47,7 +48,7 @@ ngx_event_pipe(ngx_event_pipe_t *p, ngx_
p->log->action = "reading upstream";
- if (ngx_event_pipe_read_upstream(p) == NGX_ABORT) {
+ if (ngx_event_pipe_read_upstream(p, 0) == NGX_ABORT) {
return NGX_ABORT;
}
@@ -95,8 +96,27 @@ ngx_event_pipe(ngx_event_pipe_t *p, ngx_
}
+ngx_int_t
+ngx_event_pipe_flush(ngx_event_pipe_t *p)
+{
+ p->log->action = "reading upstream";
+
+ if (ngx_event_pipe_read_upstream(p, 1) == NGX_ABORT) {
+ return NGX_ABORT;
+ }
+
+ p->log->action = "sending to client";
+
+ if (ngx_event_pipe_write_to_downstream(p) == NGX_ABORT) {
+ return NGX_ABORT;
+ }
+
+ return NGX_OK;
+}
+
+
static ngx_int_t
-ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
+ngx_event_pipe_read_upstream(ngx_event_pipe_t *p, ngx_int_t do_flush)
{
ssize_t n, size;
ngx_int_t rc;
@@ -104,6 +124,9 @@ ngx_event_pipe_read_upstream(ngx_event_p
ngx_chain_t *chain, *cl, *ln;
if (p->upstream_eof || p->upstream_error || p->upstream_done) {
+ if (do_flush) {
+ goto flush;
+ }
return NGX_OK;
}
@@ -338,6 +361,8 @@ ngx_event_pipe_read_upstream(ngx_event_p
}
}
+flush:
+
#if (NGX_DEBUG)
for (cl = p->busy; cl; cl = cl->next) {
@@ -945,7 +970,7 @@ ngx_event_pipe_add_free_buf(ngx_event_pi
return NGX_OK;
}
- /* the first free buf is partialy filled, thus add the free buf after it */
+ /* the first free buf is partially filled, thus add the free buf after it */
cl->next = p->free_raw_bufs->next;
p->free_raw_bufs->next = cl;
Index: nginx-catap/nginx/src/event/ngx_event_pipe.h
===================================================================
--- nginx-catap.orig/nginx/src/event/ngx_event_pipe.h
+++ nginx-catap/nginx/src/event/ngx_event_pipe.h
@@ -87,6 +87,7 @@ struct ngx_event_pipe_s {
ngx_int_t ngx_event_pipe(ngx_event_pipe_t *p, ngx_int_t do_write);
+ngx_int_t ngx_event_pipe_flush(ngx_event_pipe_t *p);
ngx_int_t ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf);
ngx_int_t ngx_event_pipe_add_free_buf(ngx_event_pipe_t *p, ngx_buf_t *b);
Index: nginx-catap/nginx/src/http/ngx_http_upstream.c
===================================================================
--- nginx-catap.orig/nginx/src/http/ngx_http_upstream.c
+++ nginx-catap/nginx/src/http/ngx_http_upstream.c
@@ -2383,6 +2383,18 @@ ngx_http_upstream_send_response(ngx_http
if (p->cacheable) {
p->temp_file->persistent = 1;
+ c = r->connection;
+
+ if (ngx_event_pipe_flush(u->pipe) == NGX_ABORT) {
+
+ if (c->destroyed) {
+ return;
+ }
+
+ ngx_http_upstream_finalize_request(r, u, 0);
+ return;
+ }
+
} else {
p->temp_file->log_level = NGX_LOG_WARN;
p->temp_file->warn = "an upstream response is buffered "
Something went wrong with that request. Please try again.