Main Page   Compound List   File List   Compound Members   File Members   Related Pages  

thread.c File Reference

#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sched.h>
#include <string.h>
#include <syslog.h>
#include "ahm.h"
#include "utils.h"
#include "thread.h"

Functions

gpointer thread_entry_point (gpointer a_user_data)
int send_registration_confirmation (const registration_info *a_reginfo)
int read_ping (registration_info *a_reginfo)
int wait_for_heartbeats (registration_info *a_reginfo)
int read_heartbeat (const registration_info *a_reginfo)
int recover_application (registration_info *a_reginfo)
void child_setup_function (gpointer a_user_data)
void cleanup_application (registration_info *a_reginfo)

Function Documentation

void child_setup_function gpointer    a_user_data
 

This function is called just before the exec so that we can use this to set the uid and gid of the child process.

void cleanup_application registration_info   a_reginfo
 

Closes open fifo descriptor and removes the fifo and reistration file. Removes the entry in the hash table.

Parameters:
a_reginfo  The registration info. for the application

int read_heartbeat const registration_info   a_reginfo
 

Returns:
SUCCESS if information read ok E_INVALID if the fifo fd or structure is invalid

int read_ping registration_info   a_reginfo
 

int recover_application registration_info   a_reginfo
 

Launches the recovery script and logs the missed heartbeat.

Parameters:
a_reginfo  The registration_info structure of the client app.
Returns:
SUCCESS on success; E_FAULT on failure to spawn thread E_INVALID is registration_info is NULL

int send_registration_confirmation const registration_info   a_reginfo
 

Sends the initial ping to the client indicating that registration was successful.

Parameters:
a_reginfo  The registration_info structure of the client
Returns:
on success, the data passed. Zero, on error.

gpointer thread_entry_point gpointer    a_user_data
 

Parameters:
a_user_data 

int wait_for_heartbeats registration_info   a_reginfo
 

This function will use the select() system call to determine when it can read something from the heartbeat FIFO. The period specified by the client application is how long the heartbeat monitor should wait for a heartbeat. The client will generally use two values, a minimum heartbeat resolution and a maximum. The maximum value will be passed to the heartbeat monitor during registration and the minimum value will be the value used by the client for sending heartbeats. It is useful to provide this range so that there is not a race condition of writing and reading the heartbeat that causes a false missed heartbeat, however, it is up to the client to utilize this feature.

The messages logged by this function are :

unregistered PID xxxxx no heartbeat received in xxx milliseconds, recovery PID xxxxx heartbeat received, but invalid. Recovering PID xxxxx

Parameters:
a_reginfo  The registration information for this application
Returns:
SUCCESS if no errors occured and application has either been recovered or unregistered itself.


Generated on Wed Oct 30 15:21:17 2002 for Application Heartbeat Monitor by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002