View | Details | Raw Unified | Return to bug 44696
Collapse All | Expand All

(-)modules/cache/mod_cache.c (-23 / +37 lines)
Lines 296-302 Link Here
296
    return ap_pass_brigade(f->next, bb);
296
    return ap_pass_brigade(f->next, bb);
297
}
297
}
298
298
299
static int cache_store_content(cache_request_rec *cache, request_rec *r, apr_bucket_brigade *in)
300
{
301
    int rv = !OK;
302
    apr_bucket *e = APR_BRIGADE_LAST(in);
303
    ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
304
             "cache: store - content %s", r->uri);
305
    rv = cache->provider->store_body(cache->handle, r, in);
306
    if (rv != APR_SUCCESS) {
307
        ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server,
308
                "cache: Cache provider's store_body failed!");
309
        return rv;
310
    }
311
    if (APR_BUCKET_IS_EOS(e)) {
312
        ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
313
                 "cache: store - eos bucket %s", r->uri);
299
314
315
        rv = cache->provider->store_headers(cache->handle, r, cache->info);
316
        if (rv != APR_SUCCESS) {
317
            ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server,
318
                    "cache: Cache provider's store_headers failed!");
319
        }
320
    }
321
    return rv;
322
}
323
300
/*
324
/*
301
 * CACHE_SAVE filter
325
 * CACHE_SAVE filter
302
 * ---------------
326
 * ---------------
Lines 363-372 Link Here
363
        /* pass the brigades into the cache, then pass them
387
        /* pass the brigades into the cache, then pass them
364
         * up the filter stack
388
         * up the filter stack
365
         */
389
         */
366
        rv = cache->provider->store_body(cache->handle, r, in);
390
        ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
391
                 "cache: store - checked content %s", r->uri);
392
        rv = cache_store_content(cache,r, in);
367
        if (rv != APR_SUCCESS) {
393
        if (rv != APR_SUCCESS) {
368
            ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server,
369
                         "cache: Cache provider's store_body failed!");
370
            ap_remove_output_filter(f);
394
            ap_remove_output_filter(f);
371
        }
395
        }
372
        return ap_pass_brigade(f->next, in);
396
        return ap_pass_brigade(f->next, in);
Lines 763-777 Link Here
763
        ap_cache_accept_headers(cache->handle, r, 1);
787
        ap_cache_accept_headers(cache->handle, r, 1);
764
    }
788
    }
765
789
766
    /* Write away header information to cache. It is possible that we are
790
    /* Save the cache headers information for an eventual write.
767
     * trying to update headers for an entity which has already been cached.
791
     * We dont come this way again.
768
     *
769
     * This may fail, due to an unwritable cache area. E.g. filesystem full,
770
     * permissions problems or a read-only (re)mount. This must be handled
771
     * later.
772
     */
792
     */
773
    rv = cache->provider->store_headers(cache->handle, r, info);
793
    cache->info = info;
774
775
    /* Did we just update the cached headers on a revalidated response?
794
    /* Did we just update the cached headers on a revalidated response?
776
     *
795
     *
777
     * If so, we can now decide what to serve to the client.  This is done in
796
     * If so, we can now decide what to serve to the client.  This is done in
Lines 783-788 Link Here
783
        apr_bucket *bkt;
802
        apr_bucket *bkt;
784
        int status;
803
        int status;
785
804
805
        ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
806
                 "cache: store - save headers %s", r->uri);
807
        rv = cache->provider->store_headers(cache->handle, r, info);
808
786
        bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
809
        bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
787
810
788
        /* Restore the original request headers and see if we need to
811
        /* Restore the original request headers and see if we need to
Lines 826-846 Link Here
826
        return ap_pass_brigade(f->next, bb);
849
        return ap_pass_brigade(f->next, bb);
827
    }
850
    }
828
851
829
    if(rv != APR_SUCCESS) {
852
    ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r->server,
830
        ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server,
853
             "cache: store - first time %s", r->uri);
831
                     "cache: store_headers failed");
854
    rv = cache_store_content(cache, r, in);
832
        ap_remove_output_filter(f);
833
834
        return ap_pass_brigade(f->next, in);
835
    }
836
837
    rv = cache->provider->store_body(cache->handle, r, in);
838
    if (rv != APR_SUCCESS) {
855
    if (rv != APR_SUCCESS) {
839
        ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, r->server,
840
                     "cache: store_body failed");
841
        ap_remove_output_filter(f);
856
        ap_remove_output_filter(f);
842
    }
857
    }
843
844
    return ap_pass_brigade(f->next, in);
858
    return ap_pass_brigade(f->next, in);
845
}
859
}
846
860

Return to bug 44696