[Openais] A patch for testamf*
Miyotaka Sakai
sakai.miyotaka at nttcom.co.jp
Fri Oct 1 01:59:04 PDT 2004
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 .
-------------- next part --------------
--- 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