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

(-)mod_disk_cache.c.rwc (-16 / +27 lines)
Lines 676-681 static apr_status_t open_header_timeout( Link Here
676
    while(1) {
676
    while(1) {
677
        if(dobj->hfd) {
677
        if(dobj->hfd) {
678
            apr_file_close(dobj->hfd);
678
            apr_file_close(dobj->hfd);
679
            dobj->hfd = NULL;
679
        }
680
        }
680
        rc = open_header(h, r, key, conf);
681
        rc = open_header(h, r, key, conf);
681
        if(rc != APR_SUCCESS && rc != CACHE_ENODATA) {
682
        if(rc != APR_SUCCESS && rc != CACHE_ENODATA) {
Lines 1209-1214 static apr_status_t recall_headers(cache Link Here
1209
    }
1210
    }
1210
1211
1211
    apr_file_close(dobj->hfd);
1212
    apr_file_close(dobj->hfd);
1213
    dobj->hfd = NULL;
1212
1214
1213
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1215
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1214
                 "disk_cache: Recalled headers for URL %s",  dobj->name);
1216
                 "disk_cache: Recalled headers for URL %s",  dobj->name);
Lines 1556-1561 static apr_status_t store_headers(cache_ Link Here
1556
            rv = apr_file_open(&dobj->hfd, dobj->hdrsfile, 
1558
            rv = apr_file_open(&dobj->hfd, dobj->hdrsfile, 
1557
                    APR_WRITE | APR_BINARY | APR_BUFFERED, 0, r->pool);
1559
                    APR_WRITE | APR_BINARY | APR_BUFFERED, 0, r->pool);
1558
            if (rv != APR_SUCCESS) {
1560
            if (rv != APR_SUCCESS) {
1561
                dobj->hfd = NULL;
1559
                return rv;
1562
                return rv;
1560
            }
1563
            }
1561
        }
1564
        }
Lines 1590-1595 static apr_status_t store_headers(cache_ Link Here
1590
        return rv;
1593
        return rv;
1591
    }
1594
    }
1592
1595
1596
    /* If the body size is unknown, the header file will be rewritten later
1597
       so we can't close it */
1598
    if(dobj->initial_size < 0) {
1599
        rv = apr_file_flush(dobj->hfd);
1600
    }
1601
    else {
1602
        rv = apr_file_close(dobj->hfd);
1603
        dobj->hfd = NULL;
1604
    }
1605
    if(rv != APR_SUCCESS) {
1606
        return rv;
1607
    }
1608
1593
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1609
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1594
                 "disk_cache: Stored headers for URL %s",  dobj->name);
1610
                 "disk_cache: Stored headers for URL %s",  dobj->name);
1595
    return APR_SUCCESS;
1611
    return APR_SUCCESS;
Lines 1666-1688 static apr_status_t replace_brigade_with Link Here
1666
                                               apr_bucket_brigade *bb)
1682
                                               apr_bucket_brigade *bb)
1667
{
1683
{
1668
    apr_status_t rv;
1684
    apr_status_t rv;
1669
    int flags;
1670
    apr_bucket *e;
1685
    apr_bucket *e;
1671
    core_dir_config *pdcfg = ap_get_module_config(r->per_dir_config,
1672
            &core_module);
1673
    disk_cache_object_t *dobj = (disk_cache_object_t *) h->cache_obj->vobj;
1686
    disk_cache_object_t *dobj = (disk_cache_object_t *) h->cache_obj->vobj;
1674
1687
1675
    flags = APR_READ|APR_BINARY;
1688
    if(dobj->fd) {
1676
#if APR_HAS_SENDFILE
1689
        apr_file_close(dobj->fd);
1677
    flags |= ((pdcfg->enable_sendfile == ENABLE_SENDFILE_OFF)
1690
        dobj->fd = NULL;
1678
            ? 0 : APR_SENDFILE_ENABLED);
1691
    }
1679
#endif
1692
    rv = open_body_timeout(r, dobj->name, dobj);
1680
1681
    rv = apr_file_open(&dobj->fd, dobj->datafile, flags, 0, r->pool);
1682
    if (rv != APR_SUCCESS) {
1693
    if (rv != APR_SUCCESS) {
1683
        ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
1694
        if(rv != CACHE_EDECLINED) {
1684
                     "disk_cache: Error opening datafile %s for URL %s",
1695
            ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
1685
                     dobj->datafile, dobj->name);
1696
                         "disk_cache: Error opening datafile %s for URL %s",
1697
                         dobj->datafile, dobj->name);
1698
        }
1686
        return rv;
1699
        return rv;
1687
    }
1700
    }
1688
1701
Lines 1922-1935 static apr_status_t store_body(cache_han Link Here
1922
1935
1923
    /* All checks were fine, close output file */
1936
    /* All checks were fine, close output file */
1924
    rv = apr_file_close(dobj->fd);
1937
    rv = apr_file_close(dobj->fd);
1938
    dobj->fd = NULL;
1925
    if(rv != APR_SUCCESS) {
1939
    if(rv != APR_SUCCESS) {
1926
        file_cache_errorcleanup(dobj, r);
1940
        file_cache_errorcleanup(dobj, r);
1927
        return rv;
1941
        return rv;
1928
    }
1942
    }
1929
1943
1930
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
1931
                 "disk_cache: Body for URL %s cached.",  dobj->name);
1932
1933
    /* Redirect to cachefile if we copied a plain file */
1944
    /* Redirect to cachefile if we copied a plain file */
1934
    if(copy_file) {
1945
    if(copy_file) {
1935
        rv = replace_brigade_with_cache(h, r, bb);
1946
        rv = replace_brigade_with_cache(h, r, bb);

Return to bug 39380