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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
