SSI: prevent fallback from emitting twice

This commit is contained in:
Aaron Jensen 2025-03-06 09:01:17 -08:00
parent 9e1cd4388a
commit b9ab9562d5
No known key found for this signature in database
GPG Key ID: C7481C94F4CA86A7
3 changed files with 21 additions and 2 deletions

View File

@ -2233,11 +2233,29 @@ static ngx_int_t
ngx_http_ssi_stub_output(ngx_http_request_t *r, void *data, ngx_int_t rc)
{
ngx_chain_t *out;
ngx_http_ssi_ctx_t *ctx;
if (rc == NGX_ERROR || r->connection->error || r->request_output) {
return rc;
}
ctx = ngx_http_get_module_ctx(r, ngx_http_ssi_filter_module);
if (ctx && ctx->stub_output_done) {
return NGX_OK;
}
if (ctx == NULL) {
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_ssi_ctx_t));
if (ctx == NULL) {
return NGX_ERROR;
}
ngx_http_set_ctx(r, ctx, ngx_http_ssi_filter_module);
}
ctx->stub_output_done = 1;
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"ssi stub output: \"%V?%V\"", &r->uri, &r->args);

View File

@ -82,6 +82,8 @@ typedef struct {
void *value_buf;
ngx_str_t timefmt;
ngx_str_t errmsg;
ngx_uint_t stub_output_done;
} ngx_http_ssi_ctx_t;

View File

@ -2526,7 +2526,6 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
if (r != r->main && r->post_subrequest) {
rc = r->post_subrequest->handler(r, r->post_subrequest->data, rc);
r->post_subrequest = NULL;
}
if (rc == NGX_ERROR