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

(-)httpd-2.0.50.orig/modules/experimental/mod_disk_cache.c (-5 / +25 lines)
Lines 116-122 Link Here
116
        *p = '\0';
116
        *p = '\0';
117
117
118
        rv = apr_dir_make(file, 
118
        rv = apr_dir_make(file, 
119
                          APR_UREAD|APR_UWRITE|APR_UEXECUTE, pool);
119
                          APR_UREAD|APR_UWRITE|APR_UEXECUTE|
120
                          APR_GREAD|APR_GWRITE|APR_GEXECUTE, pool);
120
        if (rv != APR_SUCCESS && !APR_STATUS_IS_EEXIST(rv)) {
121
        if (rv != APR_SUCCESS && !APR_STATUS_IS_EEXIST(rv)) {
121
            /* XXX */
122
            /* XXX */
122
        }
123
        }
Lines 135-140 Link Here
135
    /* move the data over */
136
    /* move the data over */
136
    if (dobj->fd) {
137
    if (dobj->fd) {
137
        apr_file_flush(dobj->fd);
138
        apr_file_flush(dobj->fd);
139
        /* Check if connection has been aborted. Do not rename the temporary
140
         * file in this case but simply delete it. Reason: Aborted connections
141
         * may lead to incomplete data files which MUST not be cached as
142
         * they deliver incomplete content in future requests.
143
         */
144
        if (r->connection->aborted) {
145
            apr_file_close(dobj->fd);
146
            dobj->fd = NULL;
147
            rv = apr_file_remove(dobj->tempfile, r->pool);
148
            if (rv != APR_SUCCESS) {
149
                /* XXX log */
150
            }
151
            ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
152
                         "cache_disk: Discarding body for URL %s "
153
                         "because connection has been aborted.",
154
                         h->cache_obj->key);
155
            return APR_INCOMPLETE;
156
        }
138
        if (!dobj->datafile) {
157
        if (!dobj->datafile) {
139
            dobj->datafile = data_file(r->pool, conf->dirlevels, conf->dirlength,
158
            dobj->datafile = data_file(r->pool, conf->dirlevels, conf->dirlength,
140
                                       conf->cache_root, h->cache_obj->key);
159
                                       conf->cache_root, h->cache_obj->key);
Lines 631-637 Link Here
631
    if (!dobj->fd) {
650
    if (!dobj->fd) {
632
        rv = apr_file_open(&dobj->fd, dobj->tempfile, 
651
        rv = apr_file_open(&dobj->fd, dobj->tempfile, 
633
                           APR_WRITE | APR_CREATE | APR_BINARY| APR_TRUNCATE | APR_BUFFERED,
652
                           APR_WRITE | APR_CREATE | APR_BINARY| APR_TRUNCATE | APR_BUFFERED,
634
                           APR_UREAD | APR_UWRITE, r->pool);
653
                           APR_OS_DEFAULT, r->pool);
635
        if (rv != APR_SUCCESS) {
654
        if (rv != APR_SUCCESS) {
636
            return rv;
655
            return rv;
637
        }
656
        }
Lines 643-651 Link Here
643
        apr_file_write(dobj->fd, str, &length);
662
        apr_file_write(dobj->fd, str, &length);
644
    }
663
    }
645
    if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(b))) {
664
    if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(b))) {
646
        file_cache_el_final(h, r);    /* Link to the perm file, and close the descriptor  */
665
        if (file_cache_el_final(h, r) == APR_SUCCESS) {    /* Link to the perm file, and close the descriptor  */
647
        ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
666
            ap_log_error(APLOG_MARK, APLOG_INFO, 0, r->server,
648
                     "disk_cache: Cached body for URL %s",  dobj->name);
667
                         "disk_cache: Cached body for URL %s",  dobj->name);
668
        }
649
    }
669
    }
650
670
651
    return APR_SUCCESS;	
671
    return APR_SUCCESS;	

Return to bug 21492