[Openais] A patch for configuration change of AMF

Steven Dake sdake at mvista.com
Mon Sep 27 13:05:40 PDT 2004


Sakai-san,

I should have noticed this before, but didn't...  There isn't a need to
do memcmps for s_addr, we can just compare directly.  The memcmps are a
little more difficult to read and use and can create mistakes..  I have
attached an updated patch.

Does this patch look good for you?

Regards
-steve

On Mon, 2004-09-27 at 03:44, Miyotaka Sakai wrote:
> Steve,
> 
> Thank you for your help .
> I've made new patch attached to this mail .
> Could you accept this patch and merge ?
> 
> Thanks.
> - Miyotaka Sakai .
> 
> 
> Miyotaka Sakai wrote:
> > Steve ,
> > 
> > I've founded some mistakes about codeing styile .
> > Of course , I will correct them .
> > 
> > The mistakes I found are in-line.
> > And I will new patch and send it .
> > 
> > Thanks -
> >  Miyotaka Sakai.
> 
> ______________________________________________________________________
> diff -Nur openais.2004-09-24.21.30/exec/amf.c openais/exec/amf.c
> --- openais.2004-09-24.21.30/exec/amf.c	2004-09-25 13:30:03.000000000 +0900
> +++ openais/exec/amf.c	2004-09-27 19:07:44.000000000 +0900
> @@ -36,6 +36,7 @@
>  #include <sys/socket.h>
>  #include <sys/un.h>
>  #include <netinet/in.h>
> +#include <arpa/inet.h>
>  #include <unistd.h>
>  #include <fcntl.h>
>  #include <stdlib.h>
> @@ -142,12 +143,17 @@
>  static int activeServiceUnitsCount (
>  	struct saAmfGroup *saAmfGroup);
>  
> -#ifdef COMPILE_OUT
> -static void enumerateComponents (
> +static void component_unregister (
> +	struct saAmfComponent *component);
> +
> +static void component_register (
> +	struct saAmfComponent *component);
> +
> +static void enumerate_components (
>  	void (*function)(struct saAmfComponent *, void *data),
>  	void *data);
>  
> -
> +#ifdef COMPILE_OUT
>  static void CSIRemove (
>  	struct conn_info *conn_info);
>  
> @@ -218,6 +224,17 @@
>  	struct conn_info *conn_info,
>  	struct req_amf_response *req_amf_response);
>  
> +static void amf_confchg_nleave (
> +	struct saAmfComponent *component,
> +	void *data);
> +
> +static void amf_confchg_njoin (
> +	struct saAmfComponent *component,
> +	void *data);
> +
> +static void amf_confchg_nsync (
> +	struct saAmfComponent *component,
> +	void *data);
>  
>  static int amf_confchg_fn (
>  	enum gmi_configuration_type configuration_type,
> @@ -460,7 +477,7 @@
>  	return (0);
>  }
>  
> -void componentUnregister (
> +static void component_unregister (
>  	struct saAmfComponent *component)
>  {
>  	struct req_exec_amf_componentunregister req_exec_amf_componentunregister;
> @@ -472,7 +489,7 @@
>  	if (component == 0 || component->local != 1) {
>  		return;
>  	}
> -	log_printf (LOG_LEVEL_DEBUG, "componentUnregister: unregistering component %s\n",
> +	log_printf (LOG_LEVEL_DEBUG, "component_unregister: unregistering component %s\n",
>  		getSaNameT (&component->name));
>  	component->probableCause = SA_AMF_NOT_RESPONDING;
>  
> @@ -494,10 +511,44 @@
>  	assert (gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED) == 0);
>  }
>  
> -#ifdef COMPILE_OUT
> +static void component_register (
> +	struct saAmfComponent *component)
> +{
> +	struct req_exec_amf_componentregister req_exec_amf_componentregister;
> +	struct iovec iovecs[2];
> +
> +	/*
> +	 * This only works on local components
> +	 */
> +	if (component == 0 || component->local != 1) {
> +		return;
> +	}
> +	log_printf (LOG_LEVEL_DEBUG, "component_register: registering component %s\n",
> +		getSaNameT (&component->name));
> +	component->probableCause = SA_AMF_NOT_RESPONDING;
> +
> +	req_exec_amf_componentregister.header.size = sizeof (struct req_exec_amf_componentregister);
> +	req_exec_amf_componentregister.header.id = MESSAGE_REQ_EXEC_AMF_COMPONENTREGISTER;
> +
> +	req_exec_amf_componentregister.source.conn_info = 0;
> +	req_exec_amf_componentregister.source.in_addr.s_addr = 0;
> +
> +	memset (&req_exec_amf_componentregister.req_lib_amf_componentregister,
> +		0, sizeof (struct req_lib_amf_componentregister));
> +	memcpy (&req_exec_amf_componentregister.req_lib_amf_componentregister.compName,
> +		&component->name,
> +		sizeof (SaNameT));
> +
> +	iovecs[0].iov_base = (char *)&req_exec_amf_componentregister;
> +	iovecs[0].iov_len = sizeof (req_exec_amf_componentregister);
> +
> +	assert (gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_RECOVERY) == 0);
> +}
> +
> +/***
>  This should be used for a partition I think
> -// This should be used for partition changes
> -void enumerateComponents (
> +**/
> +void enumerate_components (
>  	void (*function)(struct saAmfComponent *, void *data),
>  	void *data)
>  {
> @@ -545,7 +596,6 @@
>  		}
>  	}
>  }
> -#endif
>  
>  int activeServiceUnitsCount (struct saAmfGroup *saAmfGroup) {
>  	struct saAmfUnit *saAmfUnit;
> @@ -575,7 +625,7 @@
>  			saAmfComponent = list_entry (saAmfComponentList,
>  				struct saAmfComponent, saAmfComponentList);
>  
> -			if (saAmfComponent->currentHAState != SA_AMF_ACTIVE) {
> +			if (saAmfComponent->newHAState != SA_AMF_ACTIVE) {
>  				thisServiceUnitActive = 0;
>  			}
>  		}
> @@ -1640,6 +1690,51 @@
>  	return (0);
>  }
>  
> +void amf_confchg_nleave (struct saAmfComponent *component ,void *data)
> +{
> +	int size;
> +	struct in_addr *source_addr;
> +	source_addr = (struct in_addr *)data;
> +
> +	size = sizeof(struct in_addr);
> +	if (memcmp(&(component->source_addr),source_addr ,size)) {
> +		return;
> +	}
> +
> +	component->local = 1;
> +	component_unregister (component);
> +
> +	return;
> +}
> +
> +void amf_confchg_njoin (struct saAmfComponent *component ,void *data)
> +{
> +	int size;
> +
> +	size = sizeof(struct in_addr);
> +	if(memcmp(&(component->source_addr),&(this_ip.sin_addr.s_addr),size)){
> +		return;
> +	}
> +
> +	component_register (component);
> +	return;
> +}
> +
> +void amf_confchg_nsync (struct saAmfComponent *component ,void *data)
> +{
> +	int size;
> +
> +	size = sizeof(struct in_addr);
> +	if(memcmp(&(component->source_addr),&(this_ip.sin_addr.s_addr),size)){
> +		return;
> +	}
> +
> +	/* dsm change mast be needed */
> +	readinessStateSetCluster (component, component->currentReadinessState);
> +	haStateSetCluster (component, component->currentHAState);
> +
> +	return;
> +}
>  
>  static int amf_confchg_fn (
>  	enum gmi_configuration_type configuration_type,
> @@ -1647,9 +1742,33 @@
>      struct sockaddr_in *left_list, int left_list_entries,
>      struct sockaddr_in *joined_list, int joined_list_entries)
>  {
> +	int i;
> +	int size;
> +
>  	if (configuration_type == GMI_CONFIGURATION_REGULAR) {
>  		gmi_recovery_plug_unplug (amf_recovery_plug_handle);
>  	}
> +
> +	/*
> +	 * If node join , component register
> +	 */
> +        if ( joined_list_entries > 0 ) {
> +		enumerate_components (amf_confchg_njoin ,NULL);
> +		enumerate_components (amf_confchg_nsync ,NULL);
> +        }
> +
> +	/*
> +         * If node leave , component unregister
> +         */
> +        size = sizeof((member_list->sin_addr));
> +        if (memcmp(&(member_list->sin_addr), &(this_ip.sin_addr.s_addr) ,size)){
> +		return (0);
> +        }
> +
> +        for ( i = 0; i<left_list_entries ; i++ ) {
> +		enumerate_components (amf_confchg_nleave, (void *)&(left_list[i].sin_addr));
> +        }
> +
>  	return (0);
>  }
>  
> @@ -1659,7 +1778,7 @@
>  	 * Unregister all components registered to this file descriptor
>  	 */
>  	if (conn_info->service == SOCKET_SERVICE_AMF) {
> -		componentUnregister (conn_info->component);
> +		component_unregister (conn_info->component);
>  
>  		if (conn_info->component && conn_info->component->timer_healthcheck) {
>  			poll_timer_delete (aisexec_poll_handle,
> @@ -1730,6 +1849,7 @@
>  		component->local = 0;
>  		component->registered = 1;
>  		component->conn_info = req_exec_amf_componentregister->source.conn_info;
> +		component->source_addr = source_addr;
>  		component->currentReadinessState = SA_AMF_OUT_OF_SERVICE;
>  		component->newReadinessState = SA_AMF_OUT_OF_SERVICE;
>  		component->currentHAState = SA_AMF_QUIESCED;
> @@ -1784,7 +1904,7 @@
>  	struct saAmfComponent *amfProxyComponent;
>  	SaErrorT error;
>  
> -	log_printf (LOG_LEVEL_DEBUG, "Executive: ComponentUnregister for %s\n",
> +	log_printf (LOG_LEVEL_DEBUG, "Executive: Component_unregister for %s\n",
>  		getSaNameT (&req_exec_amf_componentunregister->req_lib_amf_componentunregister.compName));
>  
>  	component = findComponent (&req_exec_amf_componentunregister->req_lib_amf_componentunregister.compName);
> @@ -1946,6 +2066,7 @@
>  			req_exec_amf_readinessstateset->readinessState);
>  
>  		component->currentReadinessState = req_exec_amf_readinessstateset->readinessState;
> +		component->newReadinessState     = component->currentReadinessState;
>  		dsm (component);
>  	}
>  	
> @@ -1969,6 +2090,7 @@
>  			getSaNameT (&component->name),
>  			req_exec_amf_hastateset->haState);
>  		component->currentHAState = req_exec_amf_hastateset->haState;
> +		component->newHAState     = component->currentHAState;
>  		dsm (component);
>  	}
>  	
> diff -Nur openais.2004-09-24.21.30/exec/parse.h openais/exec/parse.h
> --- openais.2004-09-24.21.30/exec/parse.h	2004-09-25 13:30:03.000000000 +0900
> +++ openais/exec/parse.h	2004-09-26 09:06:06.000000000 +0900
> @@ -130,6 +130,7 @@
>  	int registered;
>  	int local;
>  	struct conn_info *conn_info;
> +	struct in_addr source_addr;
>  	SaNameT name;
>  	SaAmfReadinessStateT currentReadinessState;
>  	SaAmfReadinessStateT newReadinessState;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: amf-latest.patch
Type: text/x-patch
Size: 7737 bytes
Desc: not available
Url : http://lists.linux-foundation.org/pipermail/openais/attachments/20040927/df6f930a/amf-latest-0001.bin


More information about the Openais mailing list