Drew,

I ran the modified clm.c code and the binary in "test" called two.

this is 2-3 in the saftest source tree.  To apply the patch i think you
need to first run touch test/two.c


It sleeps for 4 seconds and then exits as normally expected with the
error "BAD HANDLE" which is to be expected if sleep is called before the
saHandleInstanceGet.  The reason it waits 4 seconds is because the test
program has a semaphore waiting for the exit of saClmDispatch to be
triggered.  The reason BAD_HANDLE is returned is because the handle has
been finalized.

I have attached my work so you can verify that my test case matches
yours.

Please let me know if there is anything further I can help with but it
appears from the information you have given the code works properly.

In your test program you can see where your app is stalled by running it
with gdb.

then press ctrl-c after 5-10 seconds and use the "threads" command to
generate backtraces for various threads of execution (thread 1 thread 2
etc).  I expect it may be a problem in your application.

When I run this program I get the following output:
[EMAIL PROTECTED] test]# ./two
finalize
  Does not conform the expected behaviors!
  saClmDispatch, Return value: 9, should be [EMAIL PROTECTED] test]# 


Regards
-steve

On Thu, 2007-10-25 at 16:05 -0700, Drew Moseley wrote:
> Steven Dake wrote:
> >
> > Send me a patch for the saftest and where you put the sleep and I'll
> > look if this is a valid scenario.
> >
> 
> Patch below.  I was able to reproduce this on a powerpc system without
> the sleep() but not every time.
> 
> Drew
> 
> 
> 
> --- openais-0.80.3-orig/lib/clm.c     2007-06-23 23:33:09.000000000 -0700
> +++ openais-0.80.3/lib/clm.c  2007-10-25 16:03:37.000000000 -0700
> @@ -287,6 +287,7 @@
>               return (SA_AIS_ERR_INVALID_PARAM);
>       }
> 
> +     sleep(4);
>       error = saHandleInstanceGet (&clmHandleDatabase, clmHandle,
>               (void *)&clmInstance);
>       if (error != SA_AIS_OK) {
Index: test/two.c
===================================================================
--- test/two.c	(revision 0)
+++ test/two.c	(revision 0)
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2004, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * Authors:
+ *      Yu, Ping  <[EMAIL PROTECTED]>
+ *
+ * Spec:        AIS-B.01.01
+ * Function:    saClmDispatch
+ * Description:   
+ *   Dispatch correctly, Set dispatch Flag to SA_DISPATCH_BLOCKING. The 
+ *   function completes successfully.
+ *   Return value should be SA_AIS_OK
+ * Line:        P23-1:P23-5
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <string.h>
+#include "saAis.h"
+#include "saClm.h"
+
+
+SaAisErrorT dispatch_ret = SA_AIS_OK;
+sem_t sem_start_dispatch;
+sem_t sem_stop_dispatch;
+
+static void getnode_callback(SaInvocationT invocation,
+                                SaClmClusterNodeT *clusterNode,
+                                SaAisErrorT error)
+{
+        if(error != SA_AIS_OK){
+                printf("GetNode Callback failed [%d]\n", error);
+        }
+        return;
+}
+
+static void *dispatch_thread(void *arg)
+{
+        SaClmHandleT *handle=(SaClmHandleT*)arg;
+        SaAisErrorT err;
+	sem_post(&sem_start_dispatch);
+        err = saClmDispatch(*handle, SA_DISPATCH_BLOCKING);
+        dispatch_ret = err;
+        sem_post(&sem_stop_dispatch);
+        return NULL;
+}
+
+int main(int argc, char *argv[])
+{
+        SaAisErrorT        error;
+        SaClmHandleT    clmhandle;
+        SaClmCallbacksT clmcallback = {
+                .saClmClusterNodeGetCallback
+                =       (SaClmClusterNodeGetCallbackT)getnode_callback,
+                .saClmClusterTrackCallback      = NULL
+        };
+        SaVersionT      version = { 'B', 1, 1 };
+        SaInvocationT invocation;
+        SaClmNodeIdT nodeId = SA_CLM_LOCAL_NODE_ID;
+        pthread_t thread_id;
+	int thread_ret;
+
+        int ret = 0;
+
+        error = saClmInitialize(&clmhandle, &clmcallback, &version);
+        if (error != SA_AIS_OK){
+                printf("  Does not conform the expected behaviors!\n");
+                printf("  saClmInitialize, Return value: %d, should be ", error);
+                ret = -1;
+		return ret;
+        }
+	
+        sem_init(&sem_start_dispatch, 0, 0);
+	sem_init(&sem_stop_dispatch, 0, 0);
+        thread_ret = pthread_create(&thread_id, NULL, dispatch_thread, 
+			(void*)&clmhandle);
+        if (thread_ret != 0){
+                printf("  Function \"pthread_create\" work abnormally!\n");
+                printf("  Return value: %s\n", strerror(error));
+                ret = -1;
+                goto final;
+        }
+	
+	sem_wait(&sem_start_dispatch);
+	invocation = 11;
+        error = saClmClusterNodeGetAsync(clmhandle, invocation, nodeId);
+        if (error != SA_AIS_OK){
+                printf("  Does not conform the expected behaviors!\n");
+                printf("  saClmClusterNodeGetAsync, Return value: %d, ", error);
+                ret = -1;
+                goto final;
+        }
+
+printf ("finalize\n");
+final:  error = saClmFinalize(clmhandle);
+        if(error != SA_AIS_OK){
+                printf("  Does not conform the expected behaviors!\n");
+                printf("  saClmFinalize, Return value: %d, should be SA_OK\n", 
+			error);
+        }
+	if (ret == 0){
+                sem_wait(&sem_stop_dispatch);
+                if (dispatch_ret != SA_AIS_OK){
+                        printf("  Does not conform the expected behaviors!\n");
+                        printf("  saClmDispatch, Return value: %d, should be ",
+			  dispatch_ret);
+                }
+        }
+
+
+        return ret;
+}
+
+
Index: test/Makefile
===================================================================
--- test/Makefile	(revision 1468)
+++ test/Makefile	(working copy)
@@ -51,7 +51,7 @@
 	testckpt ckptstress ckptbench \
 	ckptbenchth ckpt-rd ckpt-wr testevt testevs \
 	evsbench subscription publish evtbench unlink testclm2 testlck \
-	testmsg testcpg testcpg2 cpgbench openais-cfgtool
+	testmsg testcpg testcpg2 cpgbench openais-cfgtool two
 
 testtimer: testtimer.o $(LIBRARIES)
 	$(CC) $(LDFLAGS) -o testtimer testtimer.o ../exec/timer.o
@@ -131,6 +131,9 @@
 testclm2: testclm2.o $(LIBRARIES)
 	$(CC) $(LDFLAGS) -o testclm2 testclm2.o $(LIBS)
 
+two: two.o $(LIBRARIES)
+	$(CC) $(LDFLAGS) -o two two.o $(LIBS)
+
 testlck: testlck.o $(LIBRARIES)
 	$(CC) $(LDFLAGS) -o testlck testlck.o $(LIBS)
 
Index: Makefile.inc
===================================================================
--- Makefile.inc	(revision 1468)
+++ Makefile.inc	(working copy)
@@ -54,7 +54,7 @@
 # OPENAIS_BUILD can be defined as RELEASE or DEBUG
 #
 ifndef OPENAIS_BUILD
-	OPENAIS_BUILD=RELEASE
+	OPENAIS_BUILD=DEBUG
 endif
 
 # OPENAIS_PROFILE
Index: lib/clm.c
===================================================================
--- lib/clm.c	(revision 1468)
+++ lib/clm.c	(working copy)
@@ -291,6 +291,7 @@
 		return (SA_AIS_ERR_INVALID_PARAM);
 	}
 
+	sleep (4);
 	error = saHandleInstanceGet (&clmHandleDatabase, clmHandle,
 		(void *)&clmInstance);
 	if (error != SA_AIS_OK) {
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to