Apache HTTPD
Classes | Macros | Functions | Variables
mod_socache_shmcb.c File Reference
#include "httpd.h"
#include "http_log.h"
#include "http_request.h"
#include "http_protocol.h"
#include "http_config.h"
#include "mod_status.h"
#include "apr.h"
#include "apr_strings.h"
#include "apr_time.h"
#include "apr_shm.h"
#include "apr_want.h"
#include "apr_general.h"
#include "ap_socache.h"

Go to the source code of this file.

Classes

struct  SHMCBHeader
 
struct  SHMCBSubcache
 
struct  SHMCBIndex
 
struct  ap_socache_instance_t
 

Macros

#define APR_WANT_STRFUNC
 
#define SHMCB_MAX_SIZE   (UINT_MAX<APR_SIZE_MAX ? UINT_MAX : APR_SIZE_MAX)
 
#define DEFAULT_SHMCB_PREFIX   "socache-shmcb-"
 
#define DEFAULT_SHMCB_SUFFIX   ".cache"
 
#define ALIGNED_HEADER_SIZE   APR_ALIGN_DEFAULT(sizeof(SHMCBHeader))
 
#define ALIGNED_SUBCACHE_SIZE   APR_ALIGN_DEFAULT(sizeof(SHMCBSubcache))
 
#define ALIGNED_INDEX_SIZE   APR_ALIGN_DEFAULT(sizeof(SHMCBIndex))
 
#define SHMCB_SUBCACHE(pHeader, num)
 
#define SHMCB_MASK(pHeader, id)    SHMCB_SUBCACHE((pHeader), *(id) & ((pHeader)->subcache_num - 1))
 
#define SHMCB_MASK_DBG(pHeader, id)    *(id), (*(id) & ((pHeader)->subcache_num - 1))
 
#define SHMCB_INDEX(pSubcache, num)
 
#define SHMCB_DATA(pHeader, pSubcache)    ((unsigned char *)(pSubcache) + (pHeader)->subcache_data_offset)
 
#define SHMCB_CYCLIC_INCREMENT(val, inc, mod)    (((val) + (inc)) % (mod))
 
#define SHMCB_CYCLIC_SPACE(val1, val2, mod)
 

Functions

static void shmcb_cyclic_ntoc_memcpy (unsigned int buf_size, unsigned char *data, unsigned int dest_offset, const unsigned char *src, unsigned int src_len)
 
static void shmcb_cyclic_cton_memcpy (unsigned int buf_size, unsigned char *dest, const unsigned char *data, unsigned int src_offset, unsigned int src_len)
 
static int shmcb_cyclic_memcmp (unsigned int buf_size, unsigned char *data, unsigned int dest_offset, const unsigned char *src, unsigned int src_len)
 
static void shmcb_subcache_expire (server_rec *, SHMCBHeader *, SHMCBSubcache *, apr_time_t)
 
static int shmcb_subcache_store (server_rec *s, SHMCBHeader *header, SHMCBSubcache *subcache, unsigned char *data, unsigned int data_len, const unsigned char *id, unsigned int id_len, apr_time_t expiry)
 
static int shmcb_subcache_retrieve (server_rec *, SHMCBHeader *, SHMCBSubcache *, const unsigned char *id, unsigned int idlen, unsigned char *data, unsigned int *datalen)
 
static int shmcb_subcache_remove (server_rec *, SHMCBHeader *, SHMCBSubcache *, const unsigned char *, unsigned int)
 
static apr_status_t shmcb_subcache_iterate (ap_socache_instance_t *instance, server_rec *s, void *userctx, SHMCBHeader *header, SHMCBSubcache *subcache, ap_socache_iterator_t *iterator, unsigned char **buf, apr_size_t *buf_len, apr_pool_t *pool, apr_time_t now)
 
static const charsocache_shmcb_create (ap_socache_instance_t **context, const char *arg, apr_pool_t *tmp, apr_pool_t *p)
 
static apr_status_t socache_shmcb_cleanup (void *arg)
 
static apr_status_t socache_shmcb_init (ap_socache_instance_t *ctx, const char *namespace, const struct ap_socache_hints *hints, server_rec *s, apr_pool_t *p)
 
static void socache_shmcb_destroy (ap_socache_instance_t *ctx, server_rec *s)
 
static apr_status_t socache_shmcb_store (ap_socache_instance_t *ctx, server_rec *s, const unsigned char *id, unsigned int idlen, apr_time_t expiry, unsigned char *encoded, unsigned int len_encoded, apr_pool_t *p)
 
static apr_status_t socache_shmcb_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 apr_status_t socache_shmcb_remove (ap_socache_instance_t *ctx, server_rec *s, const unsigned char *id, unsigned int idlen, apr_pool_t *p)
 
static void socache_shmcb_status (ap_socache_instance_t *ctx, request_rec *r, int flags)
 
static apr_status_t socache_shmcb_iterate (ap_socache_instance_t *instance, server_rec *s, void *userctx, ap_socache_iterator_t *iterator, apr_pool_t *pool)
 
static void register_hooks (apr_pool_t *p)
 

Variables

static const ap_socache_provider_t socache_shmcb
 
static int *const aplog_module_index = &( socache_shmcb_module.module_index)
 

Macro Definition Documentation

◆ ALIGNED_HEADER_SIZE

#define ALIGNED_HEADER_SIZE   APR_ALIGN_DEFAULT(sizeof(SHMCBHeader))

Definition at line 51 of file mod_socache_shmcb.c.

◆ ALIGNED_INDEX_SIZE

#define ALIGNED_INDEX_SIZE   APR_ALIGN_DEFAULT(sizeof(SHMCBIndex))

Definition at line 53 of file mod_socache_shmcb.c.

◆ ALIGNED_SUBCACHE_SIZE

#define ALIGNED_SUBCACHE_SIZE   APR_ALIGN_DEFAULT(sizeof(SHMCBSubcache))

Definition at line 52 of file mod_socache_shmcb.c.

◆ APR_WANT_STRFUNC

#define APR_WANT_STRFUNC

Definition at line 28 of file mod_socache_shmcb.c.

◆ DEFAULT_SHMCB_PREFIX

#define DEFAULT_SHMCB_PREFIX   "socache-shmcb-"

Definition at line 47 of file mod_socache_shmcb.c.

◆ DEFAULT_SHMCB_SUFFIX

#define DEFAULT_SHMCB_SUFFIX   ".cache"

Definition at line 49 of file mod_socache_shmcb.c.

◆ SHMCB_CYCLIC_INCREMENT

#define SHMCB_CYCLIC_INCREMENT (   val,
  inc,
  mod 
)     (((val) + (inc)) % (mod))

Definition at line 191 of file mod_socache_shmcb.c.

◆ SHMCB_CYCLIC_SPACE

#define SHMCB_CYCLIC_SPACE (   val1,
  val2,
  mod 
)
Value:
((val2) >= (val1) ? ((val2) - (val1)) : \
((val2) + (mod) - (val1)))
apr_size_t size

Definition at line 195 of file mod_socache_shmcb.c.

◆ SHMCB_DATA

#define SHMCB_DATA (   pHeader,
  pSubcache 
)     ((unsigned char *)(pSubcache) + (pHeader)->subcache_data_offset)

Definition at line 183 of file mod_socache_shmcb.c.

◆ SHMCB_INDEX

#define SHMCB_INDEX (   pSubcache,
  num 
)
Value:
(SHMCBIndex *)(((unsigned char *)pSubcache) + \
apr_interval_time_t apr_int32_t * num
Definition apr_poll.h:273
#define ALIGNED_SUBCACHE_SIZE
#define ALIGNED_INDEX_SIZE

Definition at line 176 of file mod_socache_shmcb.c.

◆ SHMCB_MASK

#define SHMCB_MASK (   pHeader,
  id 
)     SHMCB_SUBCACHE((pHeader), *(id) & ((pHeader)->subcache_num - 1))

Definition at line 166 of file mod_socache_shmcb.c.

◆ SHMCB_MASK_DBG

#define SHMCB_MASK_DBG (   pHeader,
  id 
)     *(id), (*(id) & ((pHeader)->subcache_num - 1))

Definition at line 171 of file mod_socache_shmcb.c.

◆ SHMCB_MAX_SIZE

#define SHMCB_MAX_SIZE   (UINT_MAX<APR_SIZE_MAX ? UINT_MAX : APR_SIZE_MAX)

Definition at line 45 of file mod_socache_shmcb.c.

◆ SHMCB_SUBCACHE

#define SHMCB_SUBCACHE (   pHeader,
  num 
)
Value:
(SHMCBSubcache *)(((unsigned char *)(pHeader)) + \
(num) * ((pHeader)->subcache_size))
#define ALIGNED_HEADER_SIZE

Definition at line 159 of file mod_socache_shmcb.c.

Function Documentation

◆ register_hooks()

static void register_hooks ( apr_pool_t p)
static

Definition at line 1068 of file mod_socache_shmcb.c.

◆ shmcb_cyclic_cton_memcpy()

static void shmcb_cyclic_cton_memcpy ( unsigned int  buf_size,
unsigned char dest,
const unsigned char data,
unsigned int  src_offset,
unsigned int  src_len 
)
static

Definition at line 216 of file mod_socache_shmcb.c.

◆ shmcb_cyclic_memcmp()

static int shmcb_cyclic_memcmp ( unsigned int  buf_size,
unsigned char data,
unsigned int  dest_offset,
const unsigned char src,
unsigned int  src_len 
)
static

Definition at line 234 of file mod_socache_shmcb.c.

◆ shmcb_cyclic_ntoc_memcpy()

static void shmcb_cyclic_ntoc_memcpy ( unsigned int  buf_size,
unsigned char data,
unsigned int  dest_offset,
const unsigned char src,
unsigned int  src_len 
)
static

Definition at line 200 of file mod_socache_shmcb.c.

◆ shmcb_subcache_expire()

static void shmcb_subcache_expire ( server_rec s,
SHMCBHeader header,
SHMCBSubcache subcache,
apr_time_t  now 
)
static

Definition at line 723 of file mod_socache_shmcb.c.

◆ shmcb_subcache_iterate()

static apr_status_t shmcb_subcache_iterate ( ap_socache_instance_t instance,
server_rec s,
void *  userctx,
SHMCBHeader header,
SHMCBSubcache subcache,
ap_socache_iterator_t iterator,
unsigned char **  buf,
apr_size_t buf_len,
apr_pool_t pool,
apr_time_t  now 
)
static

Definition at line 970 of file mod_socache_shmcb.c.

◆ shmcb_subcache_remove()

static int shmcb_subcache_remove ( server_rec s,
SHMCBHeader header,
SHMCBSubcache subcache,
const unsigned char id,
unsigned int  idlen 
)
static

Definition at line 934 of file mod_socache_shmcb.c.

◆ shmcb_subcache_retrieve()

static int shmcb_subcache_retrieve ( server_rec s,
SHMCBHeader header,
SHMCBSubcache subcache,
const unsigned char id,
unsigned int  idlen,
unsigned char data,
unsigned int datalen 
)
static

Definition at line 871 of file mod_socache_shmcb.c.

◆ shmcb_subcache_store()

static int shmcb_subcache_store ( server_rec s,
SHMCBHeader header,
SHMCBSubcache subcache,
unsigned char data,
unsigned int  data_len,
const unsigned char id,
unsigned int  id_len,
apr_time_t  expiry 
)
static

Definition at line 769 of file mod_socache_shmcb.c.

◆ socache_shmcb_cleanup()

static apr_status_t socache_shmcb_cleanup ( void *  arg)
static

Definition at line 345 of file mod_socache_shmcb.c.

◆ socache_shmcb_create()

static const char * socache_shmcb_create ( ap_socache_instance_t **  context,
const char arg,
apr_pool_t tmp,
apr_pool_t p 
)
static

Definition at line 290 of file mod_socache_shmcb.c.

◆ socache_shmcb_destroy()

static void socache_shmcb_destroy ( ap_socache_instance_t ctx,
server_rec s 
)
static

Definition at line 490 of file mod_socache_shmcb.c.

◆ socache_shmcb_init()

static apr_status_t socache_shmcb_init ( ap_socache_instance_t ctx,
const char namespace,
const struct ap_socache_hints hints,
server_rec s,
apr_pool_t p 
)
static

Definition at line 355 of file mod_socache_shmcb.c.

◆ socache_shmcb_iterate()

static apr_status_t socache_shmcb_iterate ( ap_socache_instance_t instance,
server_rec s,
void *  userctx,
ap_socache_iterator_t iterator,
apr_pool_t pool 
)
static

Definition at line 695 of file mod_socache_shmcb.c.

◆ socache_shmcb_remove()

static apr_status_t socache_shmcb_remove ( ap_socache_instance_t ctx,
server_rec s,
const unsigned char id,
unsigned int  idlen,
apr_pool_t p 
)
static

Definition at line 562 of file mod_socache_shmcb.c.

◆ socache_shmcb_retrieve()

static apr_status_t socache_shmcb_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

Definition at line 535 of file mod_socache_shmcb.c.

◆ socache_shmcb_status()

static void socache_shmcb_status ( ap_socache_instance_t ctx,
request_rec r,
int  flags 
)
static

Definition at line 591 of file mod_socache_shmcb.c.

◆ socache_shmcb_store()

static apr_status_t socache_shmcb_store ( ap_socache_instance_t ctx,
server_rec s,
const unsigned char id,
unsigned int  idlen,
apr_time_t  expiry,
unsigned char encoded,
unsigned int  len_encoded,
apr_pool_t p 
)
static

Definition at line 497 of file mod_socache_shmcb.c.

Variable Documentation

◆ aplog_module_index

int* const aplog_module_index = &( socache_shmcb_module.module_index)
static

Definition at line 1081 of file mod_socache_shmcb.c.

◆ socache_shmcb

const ap_socache_provider_t socache_shmcb
static
Initial value:
= {
"shmcb",
(0x0001) ,
}
static apr_status_t socache_shmcb_store(ap_socache_instance_t *ctx, server_rec *s, const unsigned char *id, unsigned int idlen, apr_time_t expiry, unsigned char *encoded, unsigned int len_encoded, apr_pool_t *p)
static void socache_shmcb_destroy(ap_socache_instance_t *ctx, server_rec *s)
static const char * socache_shmcb_create(ap_socache_instance_t **context, const char *arg, apr_pool_t *tmp, apr_pool_t *p)
static apr_status_t socache_shmcb_iterate(ap_socache_instance_t *instance, server_rec *s, void *userctx, ap_socache_iterator_t *iterator, apr_pool_t *pool)
static apr_status_t socache_shmcb_init(ap_socache_instance_t *ctx, const char *namespace, const struct ap_socache_hints *hints, server_rec *s, apr_pool_t *p)
static apr_status_t socache_shmcb_remove(ap_socache_instance_t *ctx, server_rec *s, const unsigned char *id, unsigned int idlen, apr_pool_t *p)
static void socache_shmcb_status(ap_socache_instance_t *ctx, request_rec *r, int flags)
static apr_status_t socache_shmcb_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)

Definition at line 1055 of file mod_socache_shmcb.c.