Apache HTTPD
Classes | Macros | Typedefs | Functions | Variables
mod_heartmonitor.c File Reference
#include "httpd.h"
#include "http_config.h"
#include "http_log.h"
#include "http_core.h"
#include "http_protocol.h"
#include "apr_strings.h"
#include "apr_hash.h"
#include "apr_time.h"
#include "ap_mpm.h"
#include "scoreboard.h"
#include "mod_watchdog.h"
#include "ap_slotmem.h"
#include "heartbeat.h"

Go to the source code of this file.

Classes

struct  hm_server_t
 
struct  hm_ctx_t
 
struct  hm_slot_server_ctx_t
 

Macros

#define HM_UPDATE_SEC   (5)
 
#define HM_WATHCHDOG_NAME   ("_heartmonitor_")
 
#define SEEN_TIMEOUT   (30)
 
#define MAX_MSG_LEN   (1000)
 

Typedefs

typedef struct hm_server_t hm_server_t
 
typedef struct hm_ctx_t hm_ctx_t
 
typedef struct hm_slot_server_ctx_t hm_slot_server_ctx_t
 

Functions

static apr_status_t hm_listen (hm_ctx_t *ctx)
 
static void qs_to_table (const char *input, apr_table_t *parms, apr_pool_t *p)
 
static apr_status_t hm_update (void *mem, void *data, apr_pool_t *p)
 
static apr_status_t hm_readid (void *mem, void *data, apr_pool_t *p)
 
static apr_status_t hm_slotmem_update_stat (hm_server_t *s, apr_pool_t *pool)
 
static apr_status_t hm_slotmem_remove_stat (hm_server_t *s, apr_pool_t *pool)
 
static apr_status_t hm_file_update_stat (hm_ctx_t *ctx, hm_server_t *s, apr_pool_t *pool)
 
static apr_status_t hm_update_stat (hm_ctx_t *ctx, hm_server_t *s, apr_pool_t *pool)
 
static apr_status_t hm_file_update_stats (hm_ctx_t *ctx, apr_pool_t *p)
 
static apr_status_t hm_slotmem_update_stats (hm_ctx_t *ctx, apr_pool_t *p)
 
static apr_status_t hm_update_stats (hm_ctx_t *ctx, apr_pool_t *p)
 
static hm_server_thm_get_server (hm_ctx_t *ctx, const char *ip, const int port)
 
static void hm_processmsg (hm_ctx_t *ctx, apr_pool_t *p, apr_sockaddr_t *from, char *buf, apr_size_t len)
 
static apr_status_t hm_recv (hm_ctx_t *ctx, apr_pool_t *p)
 
static apr_status_t hm_watchdog_callback (int state, void *data, apr_pool_t *pool)
 
static int hm_post_config (apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 
static int hm_handler (request_rec *r)
 
static void hm_register_hooks (apr_pool_t *p)
 
static void * hm_create_config (apr_pool_t *p, server_rec *s)
 
static const charcmd_hm_storage (cmd_parms *cmd, void *dconf, const char *path)
 
static const charcmd_hm_listen (cmd_parms *cmd, void *dconf, const char *mcast_addr)
 
static const charcmd_hm_maxworkers (cmd_parms *cmd, void *dconf, const char *data)
 

Variables

static const ap_slotmem_provider_tstorage = NULL
 
static ap_slotmem_instance_tslotmem = NULL
 
static int maxworkers = 10
 
static const command_rec hm_cmds []
 
static int *const aplog_module_index = &( heartmonitor_module.module_index)
 

Macro Definition Documentation

◆ HM_UPDATE_SEC

#define HM_UPDATE_SEC   (5)

Definition at line 35 of file mod_heartmonitor.c.

◆ HM_WATHCHDOG_NAME

#define HM_WATHCHDOG_NAME   ("_heartmonitor_")

Definition at line 38 of file mod_heartmonitor.c.

◆ MAX_MSG_LEN

#define MAX_MSG_LEN   (1000)

Definition at line 572 of file mod_heartmonitor.c.

◆ SEEN_TIMEOUT

#define SEEN_TIMEOUT   (30)

Definition at line 166 of file mod_heartmonitor.c.

Typedef Documentation

◆ hm_ctx_t

◆ hm_server_t

◆ hm_slot_server_ctx_t

Function Documentation

◆ cmd_hm_listen()

static const char * cmd_hm_listen ( cmd_parms cmd,
void *  dconf,
const char mcast_addr 
)
static

< Forbidden in <VirtualHost>

< Forbidden in <Limit>

< Forbidden in <Directory>

< Forbidden in <Location>

< Forbidden in <Files> or <If>

< Forbidden in <Proxy>

Definition at line 836 of file mod_heartmonitor.c.

◆ cmd_hm_maxworkers()

static const char * cmd_hm_maxworkers ( cmd_parms cmd,
void *  dconf,
const char data 
)
static

< Forbidden in <VirtualHost>

< Forbidden in <Limit>

< Forbidden in <Directory>

< Forbidden in <Location>

< Forbidden in <Files> or <If>

< Forbidden in <Proxy>

Definition at line 885 of file mod_heartmonitor.c.

◆ cmd_hm_storage()

static const char * cmd_hm_storage ( cmd_parms cmd,
void *  dconf,
const char path 
)
static

< Forbidden in <VirtualHost>

< Forbidden in <Limit>

< Forbidden in <Directory>

< Forbidden in <Location>

< Forbidden in <Files> or <If>

< Forbidden in <Proxy>

Definition at line 818 of file mod_heartmonitor.c.

◆ hm_create_config()

static void * hm_create_config ( apr_pool_t p,
server_rec s 
)
static

Definition at line 801 of file mod_heartmonitor.c.

◆ hm_file_update_stat()

static apr_status_t hm_file_update_stat ( hm_ctx_t ctx,
hm_server_t s,
apr_pool_t pool 
)
static

< Create the file if not there

<

Deprecated:
See also
APR_FOPEN_CREATE

< Open the file for writing

<

Deprecated:
See also
APR_FOPEN_WRITE

< Open the file for reading

<

Deprecated:
See also
APR_FOPEN_READ

< Open the file in binary mode (This flag is ignored on UNIX because it has no meaning)

<

Deprecated:
See also
APR_FOPEN_BINARY

< Open the file for buffered I/O

<

Deprecated:
See also
APR_FOPEN_BUFFERED

< use OS's default permissions

<

Deprecated:
See also
APR_FPROT_OS_DEFAULT

< Size of the file

< Modification Time

< Read by user

< Read by group

< Read by others

Definition at line 228 of file mod_heartmonitor.c.

◆ hm_file_update_stats()

static apr_status_t hm_file_update_stats ( hm_ctx_t ctx,
apr_pool_t p 
)
static

< Create the file if not there

<

Deprecated:
See also
APR_FOPEN_CREATE

< Open the file for writing

<

Deprecated:
See also
APR_FOPEN_WRITE

< Read by user

< Read by group

< Read by others

Definition at line 407 of file mod_heartmonitor.c.

◆ hm_get_server()

static hm_server_t * hm_get_server ( hm_ctx_t ctx,
const char ip,
const int  port 
)
static

Definition at line 511 of file mod_heartmonitor.c.

◆ hm_handler()

static int hm_handler ( request_rec r)
static

< Module declines to handle

< Module has handled this stage.

Definition at line 741 of file mod_heartmonitor.c.

◆ hm_listen()

static apr_status_t hm_listen ( hm_ctx_t ctx)
static

< UDP

< Reuse addresses

< Non-blocking IO

Definition at line 76 of file mod_heartmonitor.c.

◆ hm_post_config()

static int hm_post_config ( apr_pool_t p,
apr_pool_t plog,
apr_pool_t ptemp,
server_rec s 
)
static

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

Definition at line 674 of file mod_heartmonitor.c.

◆ hm_processmsg()

static void hm_processmsg ( hm_ctx_t ctx,
apr_pool_t p,
apr_sockaddr_t from,
char buf,
apr_size_t  len 
)
static

Definition at line 531 of file mod_heartmonitor.c.

◆ hm_readid()

static apr_status_t hm_readid ( void *  mem,
void *  data,
apr_pool_t p 
)
static

Definition at line 183 of file mod_heartmonitor.c.

◆ hm_recv()

static apr_status_t hm_recv ( hm_ctx_t ctx,
apr_pool_t p 
)
static

Definition at line 573 of file mod_heartmonitor.c.

◆ hm_register_hooks()

static void hm_register_hooks ( apr_pool_t p)
static

Definition at line 793 of file mod_heartmonitor.c.

◆ hm_slotmem_remove_stat()

static apr_status_t hm_slotmem_remove_stat ( hm_server_t s,
apr_pool_t pool 
)
static

Definition at line 217 of file mod_heartmonitor.c.

◆ hm_slotmem_update_stat()

static apr_status_t hm_slotmem_update_stat ( hm_server_t s,
apr_pool_t pool 
)
static

Definition at line 195 of file mod_heartmonitor.c.

◆ hm_slotmem_update_stats()

static apr_status_t hm_slotmem_update_stats ( hm_ctx_t ctx,
apr_pool_t p 
)
static

Definition at line 478 of file mod_heartmonitor.c.

◆ hm_update()

static apr_status_t hm_update ( void *  mem,
void *  data,
apr_pool_t p 
)
static

Definition at line 169 of file mod_heartmonitor.c.

◆ hm_update_stat()

static apr_status_t hm_update_stat ( hm_ctx_t ctx,
hm_server_t s,
apr_pool_t pool 
)
static

Definition at line 398 of file mod_heartmonitor.c.

◆ hm_update_stats()

static apr_status_t hm_update_stats ( hm_ctx_t ctx,
apr_pool_t p 
)
static

Definition at line 503 of file mod_heartmonitor.c.

◆ hm_watchdog_callback()

static apr_status_t hm_watchdog_callback ( int  state,
void *  data,
apr_pool_t pool 
)
static

< Can read without blocking

< Can read without blocking

Definition at line 598 of file mod_heartmonitor.c.

◆ qs_to_table()

static void qs_to_table ( const char input,
apr_table_t parms,
apr_pool_t p 
)
static

Definition at line 130 of file mod_heartmonitor.c.

Variable Documentation

◆ aplog_module_index

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

Definition at line 912 of file mod_heartmonitor.c.

◆ hm_cmds

const command_rec hm_cmds[]
static
Initial value:
= {
{ "HeartbeatListen" , cmd_hm_listen , NULL , 128 , TAKE1, "Address to listen for heartbeat requests" },
{ "HeartbeatStorage" , cmd_hm_storage , NULL , 128 , TAKE1, "Path to store heartbeat data." },
{ "HeartbeatMaxServers" , cmd_hm_maxworkers , NULL , 128 , TAKE1, "Max number of servers when using slotmem (instead file) to store heartbeat data." },
{NULL}
}
@ TAKE1
Definition http_config.h:51
static const char * cmd_hm_storage(cmd_parms *cmd, void *dconf, const char *path)
static const char * cmd_hm_maxworkers(cmd_parms *cmd, void *dconf, const char *data)
static const char * cmd_hm_listen(cmd_parms *cmd, void *dconf, const char *mcast_addr)
return NULL
Definition mod_so.c:359

Definition at line 902 of file mod_heartmonitor.c.

◆ maxworkers

int maxworkers = 10
static

Definition at line 42 of file mod_heartmonitor.c.

◆ slotmem

ap_slotmem_instance_t* slotmem = NULL
static

Definition at line 41 of file mod_heartmonitor.c.

◆ storage

const ap_slotmem_provider_t* storage = NULL
static

Definition at line 40 of file mod_heartmonitor.c.