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

(-)modules/cache/cache_storage.c (+23 lines)
Lines 205-211 Link Here
205
            int fresh;
205
            int fresh;
206
206
207
            if (list->provider->recall_headers(h, r) != APR_SUCCESS) {
207
            if (list->provider->recall_headers(h, r) != APR_SUCCESS) {
208
#ifdef CACHE_CLEANUP
209
                /* We got an error so before leaving we have to close potential opened files */
210
                list->provider->recall_cleanup(h);
211
#endif // CACHE_CLEANUP
208
                /* TODO: Handle this error */
212
                /* TODO: Handle this error */
213
209
                return DECLINED;
214
                return DECLINED;
210
            }
215
            }
211
216
Lines 257-262 Link Here
257
                    ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS,
262
                    ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS,
258
                                r->server,
263
                                r->server,
259
                                "cache_select_url(): Vary header mismatch.");
264
                                "cache_select_url(): Vary header mismatch.");
265
266
#ifdef CACHE_CLEANUP
267
                    /* We got an error so before leaving we have to close potential opened files */
268
                    list->provider->recall_cleanup(h);
269
#endif // CACHE_CLEANUP
270
     
260
                    return DECLINED;
271
                    return DECLINED;
261
                }
272
                }
262
            }
273
            }
Lines 337-347 Link Here
337
        }
348
        }
338
        case DECLINED: {
349
        case DECLINED: {
339
            /* try again with next cache type */
350
            /* try again with next cache type */
351
352
#ifdef CACHE_CLEANUP
353
            /* We got an error so switching to the next provider we have to close potential opened files */
354
            list->provider->recall_cleanup(h);
355
#endif // CACHE_CLEANUP
356
     
340
            list = list->next;
357
            list = list->next;
341
            continue;
358
            continue;
342
        }
359
        }
343
        default: {
360
        default: {
344
            /* oo-er! an error */
361
            /* oo-er! an error */
362
363
#ifdef CACHE_CLEANUP
364
            /* We got an error so before leaving we have to close potential opened files */
365
            list->provider->recall_cleanup(h);
366
#endif // CACHE_CLEANUP
367
     
345
            return rv;
368
            return rv;
346
        }
369
        }
347
        }
370
        }
(-)modules/cache/mod_cache.h (+8 lines)
Lines 194-199 Link Here
194
};
194
};
195
195
196
#define CACHE_PROVIDER_GROUP "cache"
196
#define CACHE_PROVIDER_GROUP "cache"
197
#if defined(WIN32) || defined(WIN64)
198
#define CACHE_CLEANUP
199
#endif
197
200
198
typedef struct {
201
typedef struct {
199
    int (*remove_entity) (cache_handle_t *h);
202
    int (*remove_entity) (cache_handle_t *h);
Lines 206-211 Link Here
206
    int (*open_entity) (cache_handle_t *h, request_rec *r,
209
    int (*open_entity) (cache_handle_t *h, request_rec *r,
207
                           const char *urlkey);
210
                           const char *urlkey);
208
    int (*remove_url) (cache_handle_t *h, apr_pool_t *p);
211
    int (*remove_url) (cache_handle_t *h, apr_pool_t *p);
212
213
#ifdef CACHE_CLEANUP
214
   /* this was added to close potential file handles open by the provider */
215
    void (*recall_cleanup) (cache_handle_t *h);
216
#endif // CACHE_CLEANUP
209
} cache_provider;
217
} cache_provider;
210
218
211
/* A linked-list of authn providers. */
219
/* A linked-list of authn providers. */
(-)modules/cache/mod_disk_cache.c (+23 lines)
Lines 1071-1077 Link Here
1071
    return conf;
1071
    return conf;
1072
}
1072
}
1073
1073
1074
#ifdef CACHE_CLEANUP
1074
/*
1075
/*
1076
 * On error, this function close handles potentialy opened by previous calls to this module
1077
 */
1078
void recall_cleanup(cache_handle_t *h)
1079
{
1080
    disk_cache_object_t *dobj = (disk_cache_object_t *) h->cache_obj->vobj;
1081
    if (dobj->hfd)
1082
        apr_file_close(dobj->hfd);
1083
1084
    dobj->hfd = NULL;
1085
1086
    if (dobj->fd)
1087
        apr_file_close(dobj->fd);
1088
 
1089
    dobj->fd = NULL;
1090
}
1091
#endif // CACHE_CLEANUP
1092
 
1093
1094
 /*
1075
 * mod_disk_cache configuration directives handlers.
1095
 * mod_disk_cache configuration directives handlers.
1076
 */
1096
 */
1077
static const char
1097
static const char
Lines 1172-1177 Link Here
1172
    &create_entity,
1192
    &create_entity,
1173
    &open_entity,
1193
    &open_entity,
1174
    &remove_url,
1194
    &remove_url,
1195
#ifdef CACHE_CLEANUP
1196
    &recall_cleanup,
1197
#endif // CACHE_CLEANUP
1175
};
1198
};
1176
1199
1177
static void disk_cache_register_hook(apr_pool_t *p)
1200
static void disk_cache_register_hook(apr_pool_t *p)
(-)modules/cache/mod_mem_cache.c (+15 lines)
Lines 955-960 Link Here
955
    {NULL}
955
    {NULL}
956
};
956
};
957
957
958
#ifdef CACHE_CLEANUP
959
/*
960
 * On error, this function should close opened handles but we have nothing to do
961
 */
962
void recall_cleanup(cache_handle_t *h)
963
{
964
}
965
#endif // CACHE_CLEANUP 
966
958
static const cache_provider cache_mem_provider =
967
static const cache_provider cache_mem_provider =
959
{
968
{
960
    &remove_entity,
969
    &remove_entity,
Lines 965-970 Link Here
965
    &create_mem_entity,
974
    &create_mem_entity,
966
    &open_entity,
975
    &open_entity,
967
    &remove_url,
976
    &remove_url,
977
#ifdef CACHE_CLEANUP
978
	&recall_cleanup,
979
#endif // CACHE_CLEANUP 
968
};
980
};
969
981
970
static const cache_provider cache_fd_provider =
982
static const cache_provider cache_fd_provider =
Lines 977-982 Link Here
977
    &create_fd_entity,
989
    &create_fd_entity,
978
    &open_entity,
990
    &open_entity,
979
    &remove_url,
991
    &remove_url,
992
#ifdef CACHE_CLEANUP
993
	&recall_cleanup,
994
#endif // CACHE_CLEANUP 
980
};
995
};
981
996
982
static void register_hooks(apr_pool_t *p)
997
static void register_hooks(apr_pool_t *p)

Return to bug 45275