mirror of
https://github.com/nginx/nginx.git
synced 2025-06-08 02:02:38 +08:00
Stream: set action before each recv/send while proxying.
Now it's clear from log error message if the error occurred on client or upstream side.
This commit is contained in:
parent
0ac57648eb
commit
f39d5e8b33
@ -801,8 +801,6 @@ ngx_stream_proxy_init_upstream(ngx_stream_session_t *s)
|
|||||||
NGX_STREAM_UPSTREAM_NOTIFY_CONNECT);
|
NGX_STREAM_UPSTREAM_NOTIFY_CONNECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
c->log->action = "proxying connection";
|
|
||||||
|
|
||||||
if (u->upstream_buf.start == NULL) {
|
if (u->upstream_buf.start == NULL) {
|
||||||
p = ngx_pnalloc(c->pool, pscf->buffer_size);
|
p = ngx_pnalloc(c->pool, pscf->buffer_size);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
@ -1449,6 +1447,7 @@ static void
|
|||||||
ngx_stream_proxy_process(ngx_stream_session_t *s, ngx_uint_t from_upstream,
|
ngx_stream_proxy_process(ngx_stream_session_t *s, ngx_uint_t from_upstream,
|
||||||
ngx_uint_t do_write)
|
ngx_uint_t do_write)
|
||||||
{
|
{
|
||||||
|
char *recv_action, *send_action;
|
||||||
off_t *received, limit;
|
off_t *received, limit;
|
||||||
size_t size, limit_rate;
|
size_t size, limit_rate;
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
@ -1492,6 +1491,8 @@ ngx_stream_proxy_process(ngx_stream_session_t *s, ngx_uint_t from_upstream,
|
|||||||
received = &u->received;
|
received = &u->received;
|
||||||
out = &u->downstream_out;
|
out = &u->downstream_out;
|
||||||
busy = &u->downstream_busy;
|
busy = &u->downstream_busy;
|
||||||
|
recv_action = "proxying and reading from upstream";
|
||||||
|
send_action = "proxying and sending to client";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
src = c;
|
src = c;
|
||||||
@ -1501,6 +1502,8 @@ ngx_stream_proxy_process(ngx_stream_session_t *s, ngx_uint_t from_upstream,
|
|||||||
received = &s->received;
|
received = &s->received;
|
||||||
out = &u->upstream_out;
|
out = &u->upstream_out;
|
||||||
busy = &u->upstream_busy;
|
busy = &u->upstream_busy;
|
||||||
|
recv_action = "proxying and reading from client";
|
||||||
|
send_action = "proxying and sending to upstream";
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
@ -1508,6 +1511,8 @@ ngx_stream_proxy_process(ngx_stream_session_t *s, ngx_uint_t from_upstream,
|
|||||||
if (do_write && dst) {
|
if (do_write && dst) {
|
||||||
|
|
||||||
if (*out || *busy || dst->buffered) {
|
if (*out || *busy || dst->buffered) {
|
||||||
|
c->log->action = send_action;
|
||||||
|
|
||||||
rc = ngx_stream_top_filter(s, *out, from_upstream);
|
rc = ngx_stream_top_filter(s, *out, from_upstream);
|
||||||
|
|
||||||
if (rc == NGX_ERROR) {
|
if (rc == NGX_ERROR) {
|
||||||
@ -1551,6 +1556,8 @@ ngx_stream_proxy_process(ngx_stream_session_t *s, ngx_uint_t from_upstream,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c->log->action = recv_action;
|
||||||
|
|
||||||
n = src->recv(src, b->last, size);
|
n = src->recv(src, b->last, size);
|
||||||
|
|
||||||
if (n == NGX_AGAIN) {
|
if (n == NGX_AGAIN) {
|
||||||
@ -1620,6 +1627,8 @@ ngx_stream_proxy_process(ngx_stream_session_t *s, ngx_uint_t from_upstream,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c->log->action = "proxying connection";
|
||||||
|
|
||||||
if (src->read->eof && dst && (dst->read->eof || !dst->buffered)) {
|
if (src->read->eof && dst && (dst->read->eof || !dst->buffered)) {
|
||||||
handler = c->log->handler;
|
handler = c->log->handler;
|
||||||
c->log->handler = NULL;
|
c->log->handler = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user