Skip to content

Commit 761fc0b

Browse files
committed
bugfix: extra data would be returned when cache hits, filter finalizes, and network is very slow.
1 parent 4af6916 commit 761fc0b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/ngx_http_srcache_fetch.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,25 +152,31 @@ ngx_http_srcache_access_handler(ngx_http_request_t *r)
152152

153153
rc = ngx_http_srcache_fetch_header_filter(r);
154154

155+
dd("srcache fetch header returned %d", (int) rc);
156+
155157
if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
156158
return rc;
157159
}
158160

159-
rc = ngx_http_srcache_next_body_filter(r, ctx->body_from_cache);
161+
if (!r->filter_finalize) {
162+
rc = ngx_http_srcache_next_body_filter(r,
163+
ctx->body_from_cache);
160164

161-
if (rc == NGX_ERROR) {
162-
r->connection->error = 1;
163-
return NGX_ERROR;
164-
}
165+
if (rc == NGX_ERROR) {
166+
r->connection->error = 1;
167+
return NGX_ERROR;
168+
}
165169

166-
if (rc > NGX_OK) {
167-
return rc;
170+
if (rc > NGX_OK) {
171+
return rc;
172+
}
168173
}
169174

170175
dd("sent body from cache: %d", (int) rc);
171176
dd("finalize from here...");
172177

173-
ngx_http_finalize_request(r, NGX_OK);
178+
ngx_http_finalize_request(r, rc);
179+
174180
/* dd("r->main->count (post): %d", (int) r->main->count); */
175181
return NGX_DONE;
176182
}

0 commit comments

Comments
 (0)