openresty / lua-nginx-module

Embed the Power of Lua into NGINX HTTP servers
https://openresty.org/
11.24k stars 2.02k forks source link

Can't work with nginx-quic branch #1887

Open yongjianchn opened 3 years ago

yongjianchn commented 3 years ago

Got these errors when I use nginx-quic branch (for http3):

lua entry thread aborted: runtime error: access_by_lua()...
API disabled in the current context
stack traceback
.../lib/resty/core/request.lua:287: in function 'get_method'
...

Reason I guess: r->connection->fd is -1 for requests in quic stream, lua-nginx-module take the normal http3/quic requests as 'fake requests' or bad requests. So, lua-nginx-module can not work with http3/quic requests.

related codes:

ngx_http_lua_ffi_req_get_method(ngx_http_request_t *r)
{
    if (r->connection->fd == (ngx_socket_t) -1) {
        return NGX_HTTP_LUA_FFI_BAD_CONTEXT;
    }
    return r->method;
}
ngx_quic_create_stream(ngx_connection_t *c, uint64_t id)
{
    ...
    ngx_connection_t       *sc;
    ...
    sc = ngx_get_connection(-1, log);
    ...
}
spacewander commented 3 years ago

Nginx also uses -1 to mark fake connection: https://github.com/nginx/nginx/blob/8b927107287094f018cc6f5addc543e79f88ec74/src/core/ngx_connection.c#L1363

Does it change this behavior in the quic branch?

Unfortunately, I don't have enough time to chase it, so CC @doujiang24