You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/09/30 03:34:21 UTC
[GitHub] [apisix] fs7744 opened a new issue, #8027: bug: hold_body_chunk will missing last chunk
fs7744 opened a new issue, #8027:
URL: https://github.com/apache/apisix/issues/8027
### Current Behavior
hi
对此代码有点疑问 https://github.com/apache/apisix/blob/master/apisix/core/response.lua#L177
如果最后一个 chunk 和 eof 一起,
``` lua
if eof then
body_buffer = ctx._body_buffer
if not body_buffer then
return chunk
end
body_buffer = concat_tab(body_buffer, "", 1, body_buffer.n)
ctx._body_buffer = nil
return body_buffer
end
```
这段不会丢失掉最后的 chunk 吗?
难道apisix 在其他地方保证 eof 只会单独出现吗?
### Expected Behavior
_No response_
### Error Logs
_No response_
### Steps to Reproduce
just see code
### Environment
- APISIX version (run `apisix version`):
- Operating system (run `uname -a`):
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
- etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #8027: bug: hold_body_chunk will missing last chunk
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #8027:
URL: https://github.com/apache/apisix/issues/8027#issuecomment-1263271238
Look like this code "works in the real world".
> Nginx 的 upstream 相关模块,以及 OpenResty 的 content_by_lua,会单独发送一个设置了 last_buf 的空 buffer,来表示流的结束。这算是一个约定俗成的惯例,所以有必要在运行相关逻辑之前,检查 ngx.arg[1] 是否为空。当然反过来不一定成立,ngx.arg[2] == true 并不代表 ngx.arg[1] 一定为空。
https://segmentfault.com/a/1190000007483746
I will submit a fix to solve this problem. Anyway, the current code won't affect the correctness unless the output is from a third-party Nginx module and it doesn't follow Nginx's upstream behavior.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #8027: bug: hold_body_chunk will missing last chunk
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #8027:
URL: https://github.com/apache/apisix/issues/8027#issuecomment-1263390006
> 这难道不是问题?
The issue is used to track specific problems that are clear. My original comment about turning it into a discussion was because it wasn't clear enough (before I knew the details of it, so I said it needed a verifiable bug), not to deny that it could be a problem.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander closed issue #8027: bug: hold_body_chunk will missing last chunk
Posted by GitBox <gi...@apache.org>.
spacewander closed issue #8027: bug: hold_body_chunk will missing last chunk
URL: https://github.com/apache/apisix/issues/8027
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #8027: bug: hold_body_chunk will missing last chunk
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #8027:
URL: https://github.com/apache/apisix/issues/8027#issuecomment-1263097962
Show me the bug, otherwise I will turn this issue into a discussion.
read more: https://groups.google.com/g/openresty/c/NzbgHj4TgD4/m/bp4qBigm_k4J
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] fs7744 commented on issue #8027: bug: hold_body_chunk will missing last chunk
Posted by GitBox <gi...@apache.org>.
fs7744 commented on issue #8027:
URL: https://github.com/apache/apisix/issues/8027#issuecomment-1263206152
这段代码无论怎么看在多个chunk的情况下,最后一个chunk 始终不会加入 body_buffer 中,这难道不是问题?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] fs7744 commented on issue #8027: bug: hold_body_chunk will missing last chunk
Posted by GitBox <gi...@apache.org>.
fs7744 commented on issue #8027:
URL: https://github.com/apache/apisix/issues/8027#issuecomment-1263596111
在该修改中
https://github.com/openresty/lua-nginx-module/pull/1909
有类似避免进行 下一次 body_filter 的处理代码新增,
``` c
if (ctx->filter_busy_bufs != NULL
&& (r->connection->buffered
& (NGX_HTTP_LOWLEVEL_BUFFERED | NGX_LOWLEVEL_BUFFERED)))
{
/* Socket write buffer was full on last write.
* Try to write the remain data, if still can not write
* do not execute body_filter_by_lua otherwise the `in` chain will be
* replaced by new content from lua and buf of `in` mark as consumed.
* And then ngx_output_chain will call the filter chain again which
* make all the data cached in the memory and long ngx_chain_t link
* cause CPU 100%.
*/
rc = ngx_http_next_body_filter(r, NULL);
if (rc == NGX_ERROR) {
return rc;
}
```
所以空 buffer的约定应该可能是脆弱的,毕竟空 buffer 是 下列代码中认为读取完毕才会产生,
``` lua
local function get_body_filter_param(r, idx)
if idx == 1 then
data_p[0] = nil
local rc = C.ngx_http_lua_ffi_get_body_filter_param_body(r, data_p,
len_p)
if rc == FFI_AGAIN then
local buf = get_string_buf(len_p[0])
assert(C.ngx_http_lua_ffi_copy_body_filter_param_body(r, buf)
== FFI_OK)
return ffi_str(buf, len_p[0])
end
if len_p[0] == 0 then
return ""
end
return ffi_str(data_p[0], len_p[0])
elseif idx == 2 then
local rc = C.ngx_http_lua_ffi_get_body_filter_param_eof(r)
return rc == 1
else
return nil
end
end
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org