Forum: NGINX ngx_http_upstream_process_non_buffered_request recv question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
De7b680154f831d87d8ea48743852f14?d=identicon&s=25 gaoyan09 (Guest)
on 2016-07-14 05:10
(Received via mailing list)
size = b->end - b->last;

        if (size && upstream->read->ready) {

            n = upstream->recv(upstream, b->last, size);

            if (n == NGX_AGAIN) {
                break;
            }

            if (n > 0) {
                u->state->response_length += n;

                if (u->input_filter(u->input_filter_ctx, n) ==
NGX_ERROR) {
                    ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
                    return;
                }
            }

            do_write = 1;

            continue;
        }

Why not consider n==0 or n==NGX_ERROR as
ngx_http_upstream_process_upgraded
How handle it if upstream connection failed?

Posted at Nginx Forum:
https://forum.nginx.org/read.php?2,268278,268278#msg-268278
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2016-07-14 15:00
(Received via mailing list)
Hello!

On Wed, Jul 13, 2016 at 11:09:47PM -0400, gaoyan09 wrote:

>             if (n > 0) {
>             continue;
>         }
>
> Why not consider n==0 or n==NGX_ERROR as ngx_http_upstream_process_upgraded
> How handle it if upstream connection failed?

The upstream->read->eof and upstream->read->error flags are
checked separately in the do_write code path, if there are no
buffers to send downstream.

--
Maxim Dounin
http://nginx.org/
De7b680154f831d87d8ea48743852f14?d=identicon&s=25 gaoyan09 (Guest)
on 2016-07-14 15:21
(Received via mailing list)
thx

I see it.
This do keep sending to client if upstream connection eof or error, only
finalize request when u->busy_bufs == NULL, as all recv buffers had send
to
client

Posted at Nginx Forum:
https://forum.nginx.org/read.php?2,268278,268288#msg-268288
This topic is locked and can not be replied to.