[Openais] sam - user configurable warn signal

Steven Dake sdake at redhat.com
Wed Mar 24 15:04:03 PDT 2010


good for merge

apologies for delay

regards
-steve

On Thu, 2010-03-11 at 17:09 +0100, Jan Friesse wrote:
> Patch allows user configure a signal to be send as a warning signal
> before real SIGKILL. Of course, one can use SIGKILL to disable warning
> signal.
> 
> Regards,
>   Honza
> 
> plain text document attachment
> (2010-03-11-sam-user-configurable-warn-signal.patch)
> commit f00ba32c101f30641a8c04b02b83de18c414e5b7
> Author: Jan Friesse <jfriesse at redhat.com>
> Date:   Thu Mar 11 17:03:01 2010 +0100
> 
>     Support for user configurable warning signal
> 
> diff --git a/trunk/include/corosync/sam.h b/trunk/include/corosync/sam.h
> index 50d7d8b..bf6b069 100644
> --- a/trunk/include/corosync/sam.h
> +++ b/trunk/include/corosync/sam.h
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2009 Red Hat, Inc.
> + * Copyright (c) 2009-2010 Red Hat, Inc.
>   *
>   * All rights reserved.
>   *
> @@ -103,6 +103,18 @@ cs_error_t sam_start (void);
>  cs_error_t sam_stop (void);
>  
>  /*
> + * Set warning signal to be send. Default signal is SIGTERM. You can
> + * use SIGKILL to emulate NOT sending warning signal and just send
> + * SIGKILL.
> + *
> + * @return
> + * - CS_OK in case no problem appeared
> + * - CS_ERR_BAD_HANDLE library was not initialized by #sam_initialize or
> + *   is finalized
> + */
> +cs_error_t sam_warn_signal_set (int warn_signal);
> +
> +/*
>   * Register application. This is one of most crucial function. In case, your
>   * application will be restarted, you will always return to point after calling
>   * this function. This function can be called only once, and SAM must be initialized
> diff --git a/trunk/lib/sam.c b/trunk/lib/sam.c
> index f6f6449..9487afd 100644
> --- a/trunk/lib/sam.c
> +++ b/trunk/lib/sam.c
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2009 Red Hat, Inc.
> + * Copyright (c) 2009-2010 Red Hat, Inc.
>   *
>   * All rights reserved.
>   *
> @@ -87,6 +87,7 @@ static struct {
>  	unsigned int instance_id;
>  	int parent_fd;
>  	int term_send;
> +	int warn_signal;
>  
>  	sam_hc_callback_t hc_callback;
>  	pthread_t cb_thread;
> @@ -112,6 +113,8 @@ cs_error_t sam_initialize (
>  
>  	sam_internal_data.internal_status = SAM_INTERNAL_STATUS_INITIALIZED;
>  
> +	sam_internal_data.warn_signal = SIGTERM;
> +
>  	return (CS_OK);
>  }
>  
> @@ -225,6 +228,18 @@ exit_error:
>  }
>  
> 
> +cs_error_t sam_warn_signal_set (int warn_signal)
> +{
> +	if (sam_internal_data.internal_status != SAM_INTERNAL_STATUS_INITIALIZED &&
> +		sam_internal_data.internal_status != SAM_INTERNAL_STATUS_REGISTERED &&
> +		sam_internal_data.internal_status != SAM_INTERNAL_STATUS_STARTED) {
> +		return (CS_ERR_BAD_HANDLE);
> +	}
> +
> +	sam_internal_data.warn_signal = warn_signal;
> +
> +	return (CS_OK);
> +}
>  
>  static enum sam_parent_action_t sam_parent_handler (int pipe_fd, pid_t child_pid)
>  {
> @@ -275,10 +290,9 @@ static enum sam_parent_action_t sam_parent_handler (int pipe_fd, pid_t child_pid
>  				 */
>  				if (!sam_internal_data.term_send) {
>  					/*
> -					 * We didn't send SIGTERM (warning) yet.
> +					 * We didn't send warn_signal yet.
>  					 */
> -
> -					kill (child_pid, SIGTERM);
> +					kill (child_pid, sam_internal_data.warn_signal);
>  
>  					sam_internal_data.term_send = 1;
>  				} else {
> diff --git a/trunk/man/sam_overview.8 b/trunk/man/sam_overview.8
> index 09e84fd..4547212 100644
> --- a/trunk/man/sam_overview.8
> +++ b/trunk/man/sam_overview.8
> @@ -50,8 +50,8 @@ the \fBfork(3)\fR system call.  This duplicate process copy contains the logic
>  for executing the SAM server.  The SAM server is responsible for requesting
>  healthchecks from the active process, and controlling the lifecycle of the
>  active process when it fails.  If the active process fails to respond to the
> -healthcheck request sent by the SAM server, it will be sent a SIGTERM signal
> -to request shutdown of the application.  After a configured time interval, the
> +healthcheck request sent by the SAM server, it will be sent a user configurable
> +signal (default SIGTERM) to request shutdown of the application.  After a configured time interval, the
>  process will be forcibly killed by being sent a SIGKILL signal.  Once the
>  active process terminates, the SAM server will create a new active process.
>  
> @@ -85,7 +85,7 @@ then once has undefined results and is not recommended or tested.
>  
>  .SH Setting warning callback
>  .P
> -A \fISIGTERM\fR signal is sent to the application when a recovery action is
> +User configurable signal (default \fISIGTERM\fR) is sent to the application when a recovery action is
>  planned.  The application can use the \fBsignal(3)\fR system call to monitor
>  for this signal.
>  
> @@ -122,5 +122,6 @@ the \fBsam_hc_callback_register(3)\fR function should be executed.
>  .BR sam_start (3),
>  .BR sam_stop (3),
>  .BR sam_register (3),
> +.BR sam_warn_signal_set (3),
>  .BR sam_hc_send (3),
>  .BR sam_hc_callback_register (3)
> diff --git a/trunk/man/sam_warn_signal_set.3 b/trunk/man/sam_warn_signal_set.3
> new file mode 100644
> index 0000000..ffc31eb
> --- /dev/null
> +++ b/trunk/man/sam_warn_signal_set.3
> @@ -0,0 +1,63 @@
> +.\"/*
> +.\" * Copyright (c) 2010 Red Hat, Inc.
> +.\" *
> +.\" * All rights reserved.
> +.\" *
> +.\" * Author: Jan Friesse (jfriesse at redhat.com)
> +.\" *
> +.\" * This software licensed under BSD license, the text of which follows:
> +.\" *
> +.\" * Redistribution and use in source and binary forms, with or without
> +.\" * modification, are permitted provided that the following conditions are met:
> +.\" *
> +.\" * - Redistributions of source code must retain the above copyright notice,
> +.\" *   this list of conditions and the following disclaimer.
> +.\" * - Redistributions in binary form must reproduce the above copyright notice,
> +.\" *   this list of conditions and the following disclaimer in the documentation
> +.\" *   and/or other materials provided with the distribution.
> +.\" * - Neither the name of the Red Hat, Inc. nor the names of its
> +.\" *   contributors may be used to endorse or promote products derived from this
> +.\" *   software without specific prior written permission.
> +.\" *
> +.\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> +.\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> +.\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> +.\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> +.\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> +.\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> +.\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> +.\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> +.\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> +.\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> +.\" * THE POSSIBILITY OF SUCH DAMAGE.
> +.\" */
> +.TH "SAM_WARN_SIGNAL_SET" 3 "03/11/2010" "corosync Man Page" "Corosync Cluster Engine Programmer's Manual"
> +
> +.SH NAME
> +.P
> +sam_warn_signal_set \- Set warn signal
> +
> +.SH SYNOPSIS
> +.P
> +\fB#include <corosync/sam.h>\fR
> +
> +.P
> +\fBcs_error_t sam_warn_signal_set (int warn_signal);\fR
> +
> +.SH DESCRIPTION
> +.P
> +The \fBsam_warn_signal_set\fR function is used to configure warning signal
> +sent before real killing of unresponsive application. Default value is
> +SIGTERM. SIGKILL can be used to emulate "not warning signal send" behaviour.
> +
> +.SH RETURN VALUE
> +.P
> +This call return CS_OK value if successful, otherwise and error is returned.
> +
> +.SH ERRORS
> +.TP
> +CS_ERR_BAD_HANDLE
> +component was not initialized by calling \fBsam_initialize(3)\fR or it was finalized.
> +
> +.SH "SEE ALSO"
> +.BR sam_initialize (3)
> _______________________________________________
> Openais mailing list
> Openais at lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/openais



More information about the Openais mailing list