api7 / ngx_multi_upstream_module

ngx_multi_upstream_module for nginx
BSD 2-Clause "Simplified" License
9 stars 5 forks source link

nginx event timer did not work as expected #14

Open ShenFeng312 opened 3 months ago

ShenFeng312 commented 3 months ago

https://github.com/apache/apisix/issues/10620

ShenFeng312 commented 3 months ago

The bug is caused by differences between OpenResty and Nginx.

In Nginx's ngx_http_upstream.c:

if (!u->request_body_sent) {
        u->request_body_sent = 1;

        if (u->header_sent) {
            return;
        }

        ngx_add_timer(c->read, u->conf->read_timeout);

        if (c->read->ready) {
            ngx_http_upstream_process_header(r, u);
            return;
        }
    }

The added read_timeout is u->conf->read_timeout.

However, in OpenResty, due to the HAVE_NGX_UPSTREAM_TIMEOUT_FIELDS macro, OpenResty directly uses u->read_timeout.

But the ngx_multi_upstream_module does not account for this difference.