ha.c File Reference

#include <stdlib.h>
#include <time.h>
#include <poll.h>
#include "ha.h"
#include "seas.h"
#include "../../mem/mem.h"
#include "../../mem/shm_mem.h"

Include dependency graph for ha.c:

Go to the source code of this file.

Functions

char * create_ping_event (int *evt_len, int flags, unsigned int *seqno)
void destroy_pingtable (struct ha *table)
int init_pingtable (struct ha *table, int timeout, int maxpings)
static int parse_ping (char *string, int *ping_period, int *pings_lost, int *ping_timeout)
int prepare_ha (void)
int print_pingtable (struct ha *ta, int idx, int lock)
static int send_ping (struct as_entry *the_as, struct timeval *now)
int spawn_pinger (void)

Variables

char * jain_ping_config = 0
int jain_ping_period = 0
int jain_ping_timeout = 0
int jain_pings_lost = 0
pid_t pinger_pid
char * servlet_ping_config = 0
int servlet_ping_period = 0
int servlet_ping_timeout = 0
int servlet_pings_lost = 0
int use_ha = 0


Function Documentation

char* create_ping_event ( int *  evt_len,
int  flags,
unsigned int *  seqno 
)

event_length(4) UNSIGNED INT includes the length 4 bytes itself type(1), processor_id(1), 0 means nobody, 0xFF means everybody, 0<N<0xFF means processor with id=N flags(4), ping_num(4),

NOT REENTRANT (uses static local var to store ping seqno.)

returns 0 on error pointer to the buffer on success

Definition at line 371 of file ha.c.

References LM_ERR, PING_AC, and shm_malloc().

Referenced by send_ping().

void destroy_pingtable ( struct ha table  )  [inline]

Definition at line 345 of file ha.c.

References ha::mutex, ha::pings, and shm_free.

Referenced by add_new_as(), dispatcher_main_loop(), and init_pingtable().

int init_pingtable ( struct ha table,
int  timeout,
int  maxpings 
) [inline]

Initializes the high availability (ha) structure

returns 0 on success -1 on error

Definition at line 317 of file ha.c.

References ha::begin, destroy_pingtable(), ha::end, LM_ERR, ha::mutex, ha::pings, shm_malloc(), ha::size, ha::timed_out_pings, and ha::timeout.

Referenced by add_new_as().

static int parse_ping ( char *  string,
int *  ping_period,
int *  pings_lost,
int *  ping_timeout 
) [inline, static]

Parses the PING configuration string. Its format is "ping_period:pings_lost:ping_timeout" ping_period : time between pings pings_lost: number of lost pings before failure ping_timeout: time to consider a ping failed

returns 0 if config is not set -1 if config is malformed (unable to parse); 1 if config is successfully set

Definition at line 118 of file ha.c.

References LM_ERR.

Referenced by prepare_ha().

int prepare_ha ( void   ) 

returns: 0 if no High Availability 1 if High Availability -1 if config error

Definition at line 55 of file ha.c.

References jain_ping_config, jain_ping_period, jain_ping_timeout, jain_pings_lost, LM_DBG, parse_ping(), servlet_ping_config, servlet_ping_period, servlet_ping_timeout, servlet_pings_lost, and use_ha.

Referenced by seas_init().

int print_pingtable ( struct ha ta,
int  idx,
int  lock 
)

Definition at line 76 of file ha.c.

References ha::begin, ha::count, ha::mutex, and ha::size.

Referenced by dispatch_actions(), process_pings(), and process_pong().

static int send_ping ( struct as_entry the_as,
struct timeval *  now 
) [inline, static]

sends a ping to the app-server, and uses now as sent time

returns 0 on success -1 on error

Definition at line 250 of file ha.c.

References as_entry::as, as_msg::as, ha::count, create_ping_event(), ha::end, ping::id, app_server::jain_pings, as_msg::len, LM_ERR, as_msg::msg, ha::mutex, ha::pings, ping::sent, shm_free, shm_malloc(), ha::size, as_entry::u, and write_pipe.

Referenced by spawn_pinger().

int spawn_pinger ( void   ) 

we spawn a pinger process.

some day we could spawn a pinger-thread instead of a process..

returns: -1 on error;

Definition at line 170 of file ha.c.

References as_entry::as, as_list, AS_TYPE, as_entry::connected, is_dispatcher, jain_ping_period, LM_ERR, my_as, as_entry::next, NULL, pinger_pid, send_ping(), servlet_ping_period, timeout, as_entry::type, and whoami.

Referenced by dispatcher_main_loop().


Variable Documentation

char* jain_ping_config = 0

if any of these global ping vars is set to 0, then this kind of ping is DISABLED

Definition at line 34 of file ha.c.

Referenced by prepare_ha().

Definition at line 35 of file ha.c.

Referenced by add_new_as(), prepare_ha(), and spawn_pinger().

Definition at line 37 of file ha.c.

Referenced by add_new_as(), dispatch_actions(), and prepare_ha().

int jain_pings_lost = 0

Definition at line 36 of file ha.c.

Referenced by prepare_ha().

pid_t pinger_pid

Definition at line 45 of file ha.c.

Referenced by spawn_pinger().

Definition at line 39 of file ha.c.

Referenced by prepare_ha().

Definition at line 40 of file ha.c.

Referenced by add_new_as(), prepare_ha(), and spawn_pinger().

Definition at line 42 of file ha.c.

Referenced by add_new_as(), dispatch_actions(), and prepare_ha().

Definition at line 41 of file ha.c.

Referenced by prepare_ha().

int use_ha = 0

Definition at line 44 of file ha.c.

Referenced by add_new_as(), dispatch_actions(), dispatcher_main_loop(), and prepare_ha().


Generated on Wed May 23 06:01:04 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6