shctx_lock(shctx_ptr(cache));
res = entry_exist(cache, s->txn->cache_hash);
- /* We must not use an entry that is not complete. */
- if (res && res->complete) {
+ /* We must not use an entry that is not complete but the check will be
+ * performed after we look for a potential secondary entry (in case of
+ * Vary). */
+ if (res) {
struct appctx *appctx;
entry_block = block_ptr(res);
shctx_row_inc_hot(shctx_ptr(cache), entry_block);
res = NULL;
}
- /* We looked for a valid secondary entry and could not find one,
- * the request must be forwarded to the server. */
- if (!res) {
+ /* We either looked for a valid secondary entry and could not
+ * find one, or the entry we want to use is not complete. We
+ * can't use the cache's entry and must forward the request to
+ * the server. */
+ if (!res || !res->complete) {
shctx_lock(shctx_ptr(cache));
shctx_row_dec_hot(shctx_ptr(cache), entry_block);
shctx_unlock(shctx_ptr(cache));