[Openais] Re: A patch for testamf*

Steven Dake sdake at mvista.com
Fri Oct 1 18:26:15 PDT 2004


Sakai-san,

healthcheck count should be unsigned int and set to 0xFFFFFFFF (instead
of -1).

The rest of the patch looks good.  Feel free to apply once these few
things are solved.

Thanks!
-steve

On Fri, 2004-10-01 at 01:59, Miyotaka Sakai wrote:
> steve,
> 
> I made a patch attached to this message .
> This patch is for testamf6.c
> and to reduce printf output when HealthcheckCallback invoked .
> 
> If you accept this patch ,I 'll add same change to testamf1,3,4,5.
> 
> Thanks -
> Miyotaka Sakai .
> 
> ______________________________________________________________________
> --- openais.2004-09-24.21.30/test/testamf6.c	2004-09-25 13:30:03.000000000 +0900
> +++ ./openais/test/testamf6.c	2004-10-01 16:47:34.000000000 +0900
> @@ -66,21 +66,25 @@
>  	memcpy (name->value, str, name->length);
>  }
>  
> -int healthcheck_count = 0;
> +int healthcheck_count = -1;
> +int healthcheck_no = 0;
>  void HealthcheckCallback (SaInvocationT invocation,
>  	const SaNameT *compName,
>  	SaAmfHealthcheckT checkType)
>  {
>  	SaErrorT res;
>  
> -//	if (healthcheck_count++ % 20 == 19) {
> -		printf ("20 HealthcheckCallback have occured for component: ");
> -		printSaNameT ((SaNameT *)compName);
> -		printf ("\n");
> -//	}
> +	if (healthcheck_count != -1) {
> +		if (healthcheck_no++ %healthcheck_count == 0) {
> +			printf ("%d HealthcheckCallback have occured for component: ",healthcheck_no);
> +			printSaNameT ((SaNameT *)compName);
> +			printf ("\n");
> +		}
> +	}
>  	res = saAmfResponse (invocation, SA_OK);
> -	printf ("response res is %d\n", res);
> -
> +	if (res != SA_OK) {
> +		printf ("response res is %d\n", res);
> +	}
>  }
>  
>  void ReadinessStateSetCallback (SaInvocationT invocation,
> @@ -240,26 +244,54 @@
>          exit (0);
>  }
>  
> -int main (void) {
> +int main (int argc, char **argv) {
>  	SaAmfHandleT handle;
>  	int result;
>  	int select_fd;
>  	fd_set read_fds;
>  	SaNameT compName;
> +	extern char *optarg;
> +	extern int optind;
> +	int c;
> +
> +	memset (&compName, 0, sizeof (SaNameT));
>  
>  	signal (SIGINT, sigintr_handler);
>  
> +	while (1) {
> +		c = getopt(argc,argv,"h:n:");
> +		if (c==-1) {
> +			break;
> +		}
> +		switch (c) {
> +		case 0 :
> +			break;
> +		case 'h':
> +			sscanf (optarg,"%d" ,&healthcheck_count);
> +			break;
> +		case 'n':
> +			setSanameT (&compName, optarg);
> +			break;
> +		default :
> +			break;
> +		}
> +	}
> +
>  	result = saAmfInitialize (&handle, &amfCallbacks, &version);
>  	if (result != SA_OK) {
>  		printf ("initialize result is %d\n", result);
>  		exit (1);
>  	}
> +	printf ("initialize result is %d\n", result);
>  
>  	FD_ZERO (&read_fds);
>  	saAmfSelectionObjectGet (&handle, &select_fd);
>  	FD_SET (select_fd, &read_fds);
>  
> -	setSanameT (&compName, "comp_b_in_su_z");
> +	if (compName.length <= 0){
> +		printf( "compName.length = %d\n" ,compName.length );
> +		setSanameT (&compName, "comp_b_in_su_z");		
> +	}
>  
>  	result = saAmfComponentRegister (&handle, &compName, NULL);
>  	printf ("register result is %d (should be 1)\n", result);




More information about the Openais mailing list