Go to the source code of this file.
Compounds | |
struct | ping_data |
Defines | |
#define | STRING_LENGTH 256 |
#define | FILE_LINE_LENGTH 256 |
#define | REGISTRATION_TIMEOUT 3 |
Functions | |
int | ahm_initialize (const char *a_fifoname, int *a_fifo_fd, void **a_reginfo) |
int | ahm_shutdown (void **a_client_reg_info) |
int | ahm_register (pid_t a_pid, unsigned long a_id, const char *a_recovery_script, const char *a_process_name, unsigned long a_min_interval, unsigned long a_max_interval, void **a_client_reg_info) |
int | ahm_unregister (void **a_client_reg_info) |
int | ahm_send_heartbeat (void) |
int | ahm_add_heartbeat_timer_callback (const void *a_client_reg_info) |
int | ahm_remove_heartbeat_timer_callback (void) |
int | ahm_send_heartbeat_to_fifo (int a_fifo_fd) |
|
|
|
This value determines when registration is considered a failure |
|
|
|
This function may be used for sending heartbeats using the system timer. It should be called after registration has taken place. It uses the SIGALRM signal to call the ahm_send_heartbeat() function within the heartbeat interval. The heartbeat interval value used will be the minimum interval so as to not create a race condition with the daemon. Use of this function is optional and provided as a convenience for setting up recurring heartbeats.
|
|
This is the first function that a client application should call to start using the heartbeat service. The client must provide the name of the heartbeat FIFO that it will use to send heartbeat through. If the file exists already, then EEXIST will be returned from the mkfifo() call. The client application must provide a different FIFO name for each heartbeat that it wishes to generate. Any failure from issuing the mkfifo() call or the open() call to access the FIFO will be returned by this function. See the manual pages for these two function calls for more information. After successful completion of this call, the client should issue ahm_register(). It is also convenient to set up a callback at this time to handle sending heartbeats so that a heartbeat is not missed immediately after registration if there is a short period between heartbeats.
|
|
This function will fill in the internal registration structure and then create the heartbeat fifo and open it. If this succedes, it will then create the registration file. Successful return of this function does not guarantee successful registration. Successful registration is determined by two methods. The first is observing the log message indicating that the application successfully registered. The second is in being able to send a heartbeat within the timeout specified. If sending the heartbeat would block after the specified timeout, then the registration has failed. If the registration file is valid, the registration file will be removed. If it is invalid, the file will remain so that it can be inspected. The system log should be queried to further determine the failure of registration for this application. For all strings provided, they are truncated to STRING_LENGTH. Applications using longer strings may fail registration due to truncation.
|
|
Uninstalls the signal handler and removes the timer issuing the SIGALRM signal. This is the companion function to ahm_add_heartbeat_timer_callback().
|
|
This may be used by the client application to send a single heartbeat. It may also be used by the client as a callback, such as in setting up a signal handler for a timer. It may also be called before calling ahm_add_heartbeat_callback() and it will block for a maximum amount of time (REGISTRATION_TIMEOUT) until it can write to the FIFO. This functionality is provided so that the application will know if registration has succeeded within a certain reasonable amount of time. This function is also used when the client calls ahm_add_heartbeat_timer_callback(), which handles installing a signal handler and a timer for sending heartbeats. This function is used to send a single heartbeat to the heartbeat FIFO. It will timeout after REGISTRATION_TIMEOUT seconds, afterwhich it will be assumed that registration has failed if this is the first call. If after the first successful write and the function returns without sending a heartbeat, it is assumed that the heartbeat service is down. In such a case, as long as the registration file remains, then the client should continue to attempt to send a heartbeat to the service. Failure to continue to send a heartbeat, even when the service appears to be down or not responding, could result in an undesirable recovery being initiated by the service when it returns to receive heartbeats. NOTE: This function does not handle multiple heartbeats from a single application due to how the FIFO file descriptor is handled.
|
|
This function sends a heartbeat to a specific FIFO descriptor. In all other aspects, it is identical to ahm_send_heartbeat().
|
|
The unregister function must be called before this function, in order for proper termination of the heartbeat service connection. Failure to call unregister will cause the client to be recovered.
|
|
Removes the registration file, closes and removes the hearbeat FIFO. The client information remains and the application may re-register without having to call initialize(). However, once shutdown() is called, the registration information is removed.
|