BUG#: 8570
authorharsha.bm <harsha.bm>
Tue, 28 Jul 2009 08:44:09 +0000 (08:44 +0000)
committerharsha.bm <harsha.bm>
Tue, 28 Jul 2009 08:44:09 +0000 (08:44 +0000)
TITLE: Update Threaded test CMPI Provider similar to 8554.
DESCRIPTION: updated the test provider to ensure that all threads start during initialize thus avoiding a condition of a thread running after the cleanup.

src/Providers/TestProviders/CMPI/TestProviderThreaded/cmpiTestCMPIThreadProvider.c

index 3a71854a592638ad53b48585261e5fc55d3559e5..7e91cacefbbeb6bf01320f0ea97989be37d710d1 100644 (file)
@@ -124,6 +124,16 @@ empty_thread (void *args)
 /* ---------------------------------------------------------------------------*/
 /*                           Thread managament functions                      */
 /* ---------------------------------------------------------------------------*/
+int getThreadCount ()
+{
+  int threadCount = 0;
+  _broker->xft->lockMutex (threadCntMutex);
+   threadCount = threads;
+  _broker->xft->unlockMutex (threadCntMutex);
+
+  return threadCount;
+}
+
 void
 initThreads ()
 {
@@ -134,7 +144,10 @@ initThreads ()
   _broker->xft->newThread (good_thread, NULL, 0);
   _broker->xft->newThread (good_thread, NULL, 0);
   _broker->xft->newThread (good_thread, NULL, 0);
-
+  while(getThreadCount() < 3)
+  {
+    _broker->xft->threadSleep (25);
+  }
 // Only enable when the PEGASUS_DEBUG flag is not set. The
 // PEGASUS_DEBUG is mostly used by developers, and when this
 // flag is disabled the CIMServer kills the threads.
@@ -159,7 +172,7 @@ deleteThreads ()
   exitNow = 1;
 
   // Wait until the number of good threads reaches zero.
-  while (threads != 0)
+  while (getThreadCount() != 0)
     {
       gettimeofday (&t, NULL);
       // Set the time wait to 2 seconds.