summaryrefslogtreecommitdiffstats
path: root/usr.sbin/nginx/src/event/ngx_event_pipe.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/nginx/src/event/ngx_event_pipe.c')
-rw-r--r--usr.sbin/nginx/src/event/ngx_event_pipe.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/usr.sbin/nginx/src/event/ngx_event_pipe.c b/usr.sbin/nginx/src/event/ngx_event_pipe.c
index 476d56e30e3..eed807d61b8 100644
--- a/usr.sbin/nginx/src/event/ngx_event_pipe.c
+++ b/usr.sbin/nginx/src/event/ngx_event_pipe.c
@@ -57,7 +57,7 @@ ngx_event_pipe(ngx_event_pipe_t *p, ngx_int_t do_write)
do_write = 1;
}
- if (p->upstream->fd != -1) {
+ if (p->upstream->fd != (ngx_socket_t) -1) {
rev = p->upstream->read;
flags = (rev->eof || rev->error) ? NGX_CLOSE_EVENT : 0;
@@ -74,7 +74,9 @@ ngx_event_pipe(ngx_event_pipe_t *p, ngx_int_t do_write)
}
}
- if (p->downstream->fd != -1 && p->downstream->data == p->output_ctx) {
+ if (p->downstream->fd != (ngx_socket_t) -1
+ && p->downstream->data == p->output_ctx)
+ {
wev = p->downstream->write;
if (ngx_handle_write_event(wev, p->send_lowat) != NGX_OK) {
return NGX_ABORT;
@@ -220,8 +222,8 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
{
/*
- * if it is allowed, then save some bufs from r->in
- * to a temporary file, and add them to a r->out chain
+ * if it is allowed, then save some bufs from p->in
+ * to a temporary file, and add them to a p->out chain
*/
rc = ngx_event_pipe_write_chain_to_temp_file(p);
@@ -454,7 +456,7 @@ ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
size_t bsize;
ngx_int_t rc;
ngx_uint_t flush, flushed, prev_last_shadow;
- ngx_chain_t *out, **ll, *cl, file;
+ ngx_chain_t *out, **ll, *cl;
ngx_connection_t *downstream;
downstream = p->downstream;
@@ -514,13 +516,10 @@ ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
}
if (p->cacheable && p->buf_to_file) {
+ ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0,
+ "pipe write chain");
- file.buf = p->buf_to_file;
- file.next = NULL;
-
- if (ngx_write_chain_to_temp_file(p->temp_file, &file)
- == NGX_ERROR)
- {
+ if (ngx_event_pipe_write_chain_to_temp_file(p) == NGX_ABORT) {
return NGX_ABORT;
}
}
@@ -858,19 +857,13 @@ ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
return NGX_OK;
}
- if (p->free) {
- cl = p->free;
- b = cl->buf;
- p->free = cl->next;
- ngx_free_chain(p->pool, cl);
-
- } else {
- b = ngx_alloc_buf(p->pool);
- if (b == NULL) {
- return NGX_ERROR;
- }
+ cl = ngx_chain_get_free_buf(p->pool, &p->free);
+ if (cl == NULL) {
+ return NGX_ERROR;
}
+ b = cl->buf;
+
ngx_memcpy(b, buf, sizeof(ngx_buf_t));
b->shadow = buf;
b->tag = p->tag;
@@ -878,14 +871,6 @@ ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
b->recycled = 1;
buf->shadow = b;
- cl = ngx_alloc_chain_link(p->pool);
- if (cl == NULL) {
- return NGX_ERROR;
- }
-
- cl->buf = b;
- cl->next = NULL;
-
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num);
if (p->in) {