28#define APR_WANT_STRFUNC
38#if AP_NEED_SET_MUTEX_PERMS
55#define DBM_FILE_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD )
57#define DEFAULT_DBM_PREFIX "socache-dbm-"
60#if !defined(DBM_FILE_SUFFIX_DIR) && !defined(DBM_FILE_SUFFIX_PAG)
61#if defined(DBM_SUFFIX)
62#define DBM_FILE_SUFFIX_DIR DBM_SUFFIX
63#define DBM_FILE_SUFFIX_PAG DBM_SUFFIX
64#elif defined(__FreeBSD__) || (defined(DB_LOCK) && defined(DB_SHMEM))
65#define DBM_FILE_SUFFIX_DIR ".db"
66#define DBM_FILE_SUFFIX_PAG ".db"
68#define DBM_FILE_SUFFIX_DIR ".dir"
69#define DBM_FILE_SUFFIX_PAG ".pag"
89 if (!
ctx->data_file) {
100#if AP_NEED_SET_MUTEX_PERMS
111 "Can't change owner of %s",
name);
120 const char *
namespace,
124#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
140 "could not use default path '%s' for DBM socache",
149#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
152 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10277)
153 "Cannot load socache DBM library '%s': %s",
154 err->reason, err->msg);
159 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00804)
160 "Cannot create socache DBM file `%s'",
167 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00804)
168 "Cannot create socache DBM file `%s'",
178#if AP_NEED_SET_MUTEX_PERMS
217#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
230 "data size too large for DBM socache: %d >= %d",
235 if ((
idlen + nData) >= 950 ) {
237 "data size too large for DBM socache: %d >= %d",
238 (
idlen + nData), 950);
256#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
259 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10278)
260 "Cannot load socache DBM library '%s' (store): %s",
261 err->reason, err->msg);
267 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00807)
268 "Cannot open socache DBM file `%s' for writing "
277 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00807)
278 "Cannot open socache DBM file `%s' for writing "
287 "Cannot store socache object to DBM file `%s'",
305 const unsigned char *
id,
unsigned int idlen,
309#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
333#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
336 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10279)
337 "Cannot load socache DBM library '%s' (fetch): %s",
338 err->reason, err->msg);
343 ap_log_error(APLOG_MARK, APLOG_ERR, rc, s, APLOGNO(00809)
344 "Cannot open socache DBM file `%s' for reading "
352 ap_log_error(APLOG_MARK, APLOG_ERR, rc, s, APLOGNO(00809)
353 "Cannot open socache DBM file `%s' for reading "
396#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
411#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
414 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10280)
415 "Cannot load socache DBM library '%s' (delete): %s",
416 err->reason, err->msg);
421 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00810)
422 "Cannot open socache DBM file `%s' for writing "
430 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00810)
431 "Cannot open socache DBM file `%s' for writing "
445#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
474#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
477 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10281)
478 "Cannot load socache DBM library '%s' (expire): %s",
479 err->reason, err->msg);
507#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
511 "Cannot open socache DBM file `%s' for "
520 "Cannot open socache DBM file `%s' for "
551#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
555 "Cannot re-open socache DBM file `%s' for "
564 "Cannot re-open socache DBM file `%s' for "
581 "DBM socache expiry: "
582 "old: %d, new: %d, removed: %d",
583 elts, elts-deleted, deleted);
589#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
605#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
608 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(10282)
609 "Cannot load socache DBM library '%s' (status retrieval): %s",
610 err->reason, err->msg);
615 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(00814)
616 "Cannot open socache DBM file `%s' for status "
624 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(00814)
625 "Cannot open socache DBM file `%s' for status "
643 if (
size > 0 && elts > 0)
644 avg = (
int)(
size / (
long)elts);
648 ap_rprintf(
r,
"cache type: <b>DBM</b>, maximum size: <b>unlimited</b><br>");
649 ap_rprintf(
r,
"current entries: <b>%d</b>, current size: <b>%ld</b> bytes<br>", elts,
size);
650 ap_rprintf(
r,
"average entry size: <b>%d</b> bytes<br>", avg);
654 ap_rputs(
"CacheMaximumSize: unlimited\n",
r);
666#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
682#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
685 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10283)
686 "Cannot load socache DBM library '%s' (iterating): %s",
687 err->reason, err->msg);
692 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00815)
693 "Cannot open socache DBM file `%s' for "
694 "iterating", ctx->data_file);
700 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00815)
701 "Cannot open socache DBM file `%s' for "
702 "iterating", ctx->data_file);
709 apr_dbm_fetch(dbm, dbmkey, &dbmval);
710 if (dbmval.dsize <= sizeof(apr_time_t) || dbmval.dptr == NULL)
713 memcpy(&expiry, dbmval.dptr, sizeof(apr_time_t));
723 "dbm `%s' entry iterated",
ctx->data_file);
733 "Failure reading first/next socache DBM file `%s' record",
Small object cache provider interface.
APR Standard Headers Support.
char * ap_runtime_dir_relative(apr_pool_t *p, const char *fname)
#define AP_DECLARE_MODULE(foo)
char * ap_server_root_relative(apr_pool_t *p, const char *fname)
request_rec int int apr_table_t const char * path
int ap_rprintf(request_rec *r, const char *fmt,...) __attribute__((format(printf
static APR_INLINE int ap_rputs(const char *str, request_rec *r)
apr_status_t ap_register_provider(apr_pool_t *pool, const char *provider_group, const char *provider_name, const char *provider_version, const void *provider)
apr_brigade_flush void * ctx
const char const apr_dbd_driver_t ** driver
const char apr_ssize_t int flags
apr_status_t() ap_socache_iterator_t(ap_socache_instance_t *instance, server_rec *s, void *userctx, const unsigned char *id, unsigned int idlen, const unsigned char *data, unsigned int datalen, apr_pool_t *pool)
#define AP_SOCACHE_PROVIDER_GROUP
#define AP_SOCACHE_FLAG_NOTMPSAFE
#define AP_SOCACHE_PROVIDER_VERSION
#define STANDARD20_MODULE_STUFF
void * ap_malloc(size_t size) __attribute__((malloc))
const char int apr_pool_t * pool
#define APR_FROM_OS_ERROR(e)
#define apr_pool_create(newpool, parent)
#define apr_pcalloc(p, size)
apr_int32_t apr_int32_t apr_int32_t err
apr_int64_t apr_interval_time_t
#define apr_time_from_sec(sec)
for(i=0;i< sconf->loaded_modules->nelts;i++)
static apr_status_t socache_dbm_iterate(ap_socache_instance_t *ctx, server_rec *s, void *userctx, ap_socache_iterator_t *iterator, apr_pool_t *pool)
static apr_status_t socache_dbm_store(ap_socache_instance_t *ctx, server_rec *s, const unsigned char *id, unsigned int idlen, apr_time_t expiry, unsigned char *ucaData, unsigned int nData, apr_pool_t *pool)
static apr_status_t socache_dbm_retrieve(ap_socache_instance_t *ctx, server_rec *s, const unsigned char *id, unsigned int idlen, unsigned char *dest, unsigned int *destlen, apr_pool_t *p)
static const ap_socache_provider_t socache_dbm
#define DEFAULT_DBM_PREFIX
static void register_hooks(apr_pool_t *p)
static apr_status_t socache_dbm_init(ap_socache_instance_t *ctx, const char *namespace, const struct ap_socache_hints *hints, server_rec *s, apr_pool_t *p)
#define DBM_FILE_SUFFIX_PAG
static void socache_dbm_destroy(ap_socache_instance_t *ctx, server_rec *s)
static const char * socache_dbm_create(ap_socache_instance_t **context, const char *arg, apr_pool_t *tmp, apr_pool_t *p)
#define DBM_FILE_SUFFIX_DIR
static void socache_dbm_status(ap_socache_instance_t *ctx, request_rec *r, int flags)
static apr_status_t socache_dbm_remove(ap_socache_instance_t *ctx, server_rec *s, const unsigned char *id, unsigned int idlen, apr_pool_t *p)
static void socache_dbm_expire(ap_socache_instance_t *ctx, server_rec *s)
Status Report Extension Module to Apache.
Multi-Processing Modules functions.
apr_interval_time_t expiry_interval
A structure that represents the current request.
A structure to store information for each virtual server.
typedef int(WSAAPI *apr_winapi_fpt_WSAPoll)(IN OUT LPWSAPOLLFD fdArray