Пример #1
0
void CSharedQueueSrv::ThreadMainL()
	{
	if (!Processes::RenameIfNotRunning(KSharedQueueSrvName))
		{
		// non dovrebbe mai accadere perche' il client non dovrebbe lanciarlo se c'e' gia' un server in esecuzione...
		RSemaphore semaphore;
		User::LeaveIfError(semaphore.OpenGlobal(KSharedQueueSrvImg));
		semaphore.Signal();
		semaphore.Close();
		return;
		}
	CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler();
	CleanupStack::PushL(activeScheduler);

	CActiveScheduler::Install(activeScheduler);

	CSharedQueueSrv::NewLC();
	//
	// Initialisation complete, now signal the client
	RSemaphore semaphore;
	User::LeaveIfError(semaphore.OpenGlobal(KSharedQueueSrvImg));

	semaphore.Signal();
	semaphore.Close();

	CActiveScheduler::Start();

	CleanupStack::PopAndDestroy(2);
	}
// ----------------------------------------------------------------------------
// CSipClientSimulatorServer::InitServerL
// ----------------------------------------------------------------------------
//
void CSipClientSimulatorServer::InitServerL()
	{
	// Open the semaphore that was created by the first client
	RSemaphore semaphore;
	User::LeaveIfError( semaphore.OpenGlobal( KSipClientSimulatorName ) );

	CActiveScheduler* scheduler = NULL;
	CSipClientSimulatorServer* srv = NULL;

	// We don't want the client waiting on the semaphore indefinitely
	// even if server start fails.
	TRAPD( err,
		{
		// Start scheduler and server
		scheduler = new( ELeave ) CActiveScheduler;
		CleanupStack::PushL( scheduler );
		CActiveScheduler::Install( scheduler );

		// Create server instance
		srv = CSipClientSimulatorServer::NewLC( );
		// Start the server using CServer::StartL()
		srv->StartL( KSipClientSimulatorName );
		// we have to pop this before crossing TRAP boundary
		CleanupStack::Pop( 2 );	// srv, scheduler
		} )
/**
* Modifier Thread entry point
*/
GLDEF_C TInt RunModifierThread(TAny* aArgs)
    {
	TInt err;
	CTestCalInterimApiModifier* modifierThread = NULL;
	CTrapCleanup* trapCleanup = CTrapCleanup::New();
	CTestStep* iTestStep = static_cast<CTestStep*>(aArgs);
	CActiveScheduler*	scheduler = new(ELeave) CActiveScheduler;

	if (scheduler)
		{
		CActiveScheduler::Install(scheduler);
    	TRAP(err, modifierThread = CTestCalInterimApiModifier::NewL(iTestStep));

    	if (err == KErrNone)
			{
			TRAP(err, modifierThread->RunTestsL());
			}
 		RSemaphore semaphoreStop;
		const TPtrC& semaphoreName = modifierThread->ModifierSemaphoreName();
		semaphoreStop.OpenGlobal(semaphoreName);

		delete modifierThread;
		modifierThread = NULL;
		delete scheduler;
		scheduler = NULL;
		delete trapCleanup;
		trapCleanup = NULL;
		
		semaphoreStop.Signal();
		semaphoreStop.Close();
		}
	
	return err;
	}
/**
 * The Contact Views thread entry point
 * @param aArgs - Command line parameters for the contact views thread
 * @return TInt - exit reason
 */
GLDEF_C TInt RunContactViewsThreadL(TAny* aArgs)
    {
	TInt err;
	CContactViews* contactViews = NULL;
	CTrapCleanup* trapCleanup = CTrapCleanup::New();
	CTestStep* testStep = static_cast<CTestStep*>(aArgs);
	CActiveScheduler*	scheduler = new(ELeave) CActiveScheduler;

	if (scheduler)
		{
		CActiveScheduler::Install(scheduler);
    	TRAP(err, contactViews = CContactViews::NewL(*testStep));

    	if (err == KErrNone)
			{
			TRAP(err, contactViews->RunTestL());
			}

		RSemaphore semaphoreStop;
		semaphoreStop.OpenGlobal(KSemaphoreName);

		delete contactViews;
		contactViews = NULL;
		delete scheduler;
		scheduler = NULL;
		delete trapCleanup;
		trapCleanup = NULL;

		semaphoreStop.Signal();
		semaphoreStop.Close();
		}

	return err;
	}
TInt MainL()
	{
	RSemaphore sem;
	sem.OpenGlobal(_L("TSysMon_Critical"));
	CleanupClosePushL(sem);
	
	_LIT(KSystemCritical, "ESystemCritical");
	_LIT(KSystemPermanent, "ESystemPermanent");

	if(CmdLineOptionL(KSystemCritical))
		{
		User::LeaveIfError(User::SetProcessCritical(User::ESystemCritical));
		RDebug::Print(_L("tsysmon_app_critical.exe is set to SystemCritical"));
		}
	
	if(CmdLineOptionL(KSystemPermanent))
		{
		User::LeaveIfError(User::SetProcessCritical(User::ESystemPermanent));
		RDebug::Print(_L("tsysmon_app_critical.exe is set to ESystemPermanent"));
		}

	RProcess::Rendezvous(KErrNone);

	sem.Wait();
	
	User::LeaveIfError(User::SetProcessCritical(User::ENotCritical));
	
	sem.Signal();
	
	CleanupStack::PopAndDestroy();

	return KErrNone;
	}
Пример #6
0
/* 
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/  
void CExPolicy_Server::ThreadFunctionL()
    {
    // Construct active scheduler
    CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler;
    CleanupStack::PushL(activeScheduler) ;

    // Install active scheduler
    // We don't need to check whether an active scheduler is already installed
    // as this is a new thread, so there won't be one
    CActiveScheduler::Install(activeScheduler);

    // Construct our server
    CExPolicy_Server::NewLC();    // anonymous

	RSemaphore semaphore;
	User::LeaveIfError(semaphore.OpenGlobal(KExapmpleServerSemaphoreName));

	// Semaphore opened ok
	semaphore.Signal();
	semaphore.Close();

	// Start handling requests
	CActiveScheduler::Start();

    CleanupStack::PopAndDestroy(2, activeScheduler);    //  anonymous CSALockServer
    }
Пример #7
0
void CMySession::ServiceL(const RMessage2& aMessage)
//
// Handle messages for this server.
//
	{
	RSemaphore svrSem;

	//CMySession &c=(CMySession &)aClient;// passed as CSession2 since fn overloads pure virtual fn
	TInt r=KErrNone;
	switch (aMessage.Function())
		{
	case ETest:
		break;
	case ENeverComplete:
		r = svrSem.OpenGlobal(KSvrSemName);
		if (r != KErrNone)
			break;
		svrSem.Signal(); // all ready for the server to be killed
		svrSem.Close();
		return;
	default:
		r=KErrNotSupported;
		}
	aMessage.Complete(r);
	}
Пример #8
0
TInt CClkNitzModel::IsNitzSrvRunning(void)
{
  TInt err=KErrNone;
  _LIT(KServer,"ClkNitzMdlServer");
  _LIT(KSem,"ClkNitzMdlStartSemaphore");
  TFindServer find(KServer);
  TFullName name;
  if(find.Next(name)!=KErrNone)
  {
    RSemaphore sem;
    TInt i=0;
    do
    {
      err=sem.OpenGlobal(KSem);
      if(err==KErrNone)
      {
        sem.Close();
        break;
      }
      User::After(1000000);
      i++;
    } while(i<6);
  }
  return err;
}
void CAlmSettingsServer::SignalL(void)
{
  RSemaphore semaphore;
  User::LeaveIfError(semaphore.OpenGlobal(KSettingsServerSemaphoreName));
  semaphore.Signal();
  semaphore.Close();
}
LOCAL_C void MainL()
/**
 * REQUIRES semaphore to sync with client as the Rendezvous()
 * calls are not available
 */
	{
	CActiveScheduler* sched=NULL;
	sched=new(ELeave) CActiveScheduler;
	CleanupStack::PushL(sched);
	CActiveScheduler::Install(sched);
	CTe_rtpwrapperCoreServer* server = NULL;
	// Create the CTestServer derived server
	TRAPD(err,server = CTe_rtpwrapperCoreServer::NewL());
	if(!err)
		{
		CleanupStack::PushL(server);
		RSemaphore sem;
		// The client API will already have created the semaphore
		User::LeaveIfError(sem.OpenGlobal(KServerName));
		CleanupStack::Pop(server);
		// Sync with the client then enter the active scheduler
		sem.Signal();
		sem.Close();
		sched->Start();
		}
	CleanupStack::Pop(sched);
	delete server;
	delete sched;
	}
Пример #11
0
LOCAL_C TInt clientThreadEntryPoint(TAny *param)
//
// The entry point for the client thread.
//
	{
	RSemaphore svrSem2;
	RSemaphore clientSem;
	TInt r = clientSem.OpenGlobal(KClientSemName);
	if (r != KErrNone)
		return r;
	RMySessionBase t;
	RMySessionBase t2;
//	RTimer rt[40];
//	TUint c;

	switch ((TUint32)param)
		{
	case 1:
		r=t.Open();
		if (r != KErrNone)
			break;
		clientSem.Signal();
		clientSem.Close();
		FOREVER
			;
	case 2:
		// Now create a lot of timers to eliminate kernel granularities
/*		for (c=0;c<40;c++)
			{
			TInt r=rt[c].CreateLocal();
			test(r==KErrNone);
			}
		for (c=0;c<39;c++)
			rt[c].Close();
*/
		r=svrSem2.OpenGlobal(KSvrSem2Name);
		if (r != KErrNone)
			break;
		clientSem.Signal();
		svrSem2.Wait();
		svrSem2.Close();
		User::After(2000000);
		r=t2.Open();
		if (r != KErrNone)
			break;
		r=t2.NeverComplete(); // r should be KErrServerTerminated
		if (r != KErrServerTerminated)
			break;
		t2.Close();
		clientSem.Signal();
		clientSem.Close();
		FOREVER
			;
	default:
		break;
		}
	return r;
	}
Пример #12
0
void CTestAppUi::ConstructL()
	{
	// Complete the UI framework's construction of the App UI.
	BaseConstructL(CEikAppUi::ENoAppResourceFile);

	iPropertyObs = new(ELeave) CPropertyObserver;
	iPropertyObs->StartL();

    //Signal that application is started
    RSemaphore sem;
    TInt err = sem.OpenGlobal(KStartShmaTestAppGood);
    if(err == KErrNone)
        {
        sem.Signal();
        sem.Close();
        }

	RFs fs;
	err = fs.Connect();
	User::LeaveIfError(err);
	CleanupClosePushL(fs);
	
	RFile file;
	err = file.Open(fs, KPanicFile, EFileRead);
	if (err == KErrNotFound)
		{
		CleanupStack::PopAndDestroy(&fs);
		// We are not using the file, so just return
		return;
		}
	else
		{
		User::LeaveIfError(err);
		CleanupClosePushL(file);
		
		TBuf8<30> buf;
		err = file.Read(buf);
		User::LeaveIfError(err);

		CleanupStack::PopAndDestroy(&file);
		err = fs.Delete(KPanicFile);

		RBuf8 writableArgs;
		writableArgs.CreateL(buf, 30);
		CleanupClosePushL(writableArgs);
		TPtr16 args16 = writableArgs.Expand();
	
		_LIT(KTestGoodProcPanic, "Panic");
	 	if (args16 == KPanicCommandLineOption1)
	 		User::Panic(KTestGoodProcPanic, KProcPanic);
	 	else if (args16 == KPanicCommandLineOption2)
			User::Panic(KTestGoodProcPanic, KErrNone);
	 	
	 	CleanupStack::PopAndDestroy(2, &fs);
		}
	}
static void SignalTestExe()
	{
	_LIT(KSchSemaphoreName, "SCHMinimalTaskHandler");
	RSemaphore sem;
	TInt ret = sem.OpenGlobal(KSchSemaphoreName);
	if (ret == KErrNone)
		{
		sem.Signal();
		sem.Close();
		}
	}
Пример #14
0
void CConcurrentDatabaseAccessBase::OpenSemaphore()
	{
	TInt success = KErrNone;

	success = iSemaphoreSignal.OpenGlobal( KSemaphoreNameOne );
	if ( success == KErrNotFound )
		{
		iSemaphoreSignal.CreateGlobal( KSemaphoreNameOne, 0 );
		success = KErrNone;
		}


	success = iSemaphoreWait.OpenGlobal( KSemaphoreNameTwo );
	if ( success == KErrNotFound )
		{
		iSemaphoreWait.CreateGlobal( KSemaphoreNameTwo, 0 );
		}

	iSemaphoreOpen = ETrue;
	}
Пример #15
0
//
// CBackupDriver::TerminateProcessL
// open the backup_child process & signal it's semaphore
// that semaphore is the signal to shut itself down cleanly
//
void CBackupDriver::TerminateProcessL()
	{
	if (!ChildProcessExists())
		User::Leave(KErrNotFound);
	
	// signal the semaphore 
	RSemaphore sem;
	User::LeaveIfError(sem.OpenGlobal(KBackupSemaphore, EOwnerProcess));
	sem.Signal();

	SelfComplete(KErrNone);
	}
Пример #16
0
/**
 *
 * CTestFrameworkMain - start testing.
 * Calls main test loop.
 *
 * @param "const TDesC& aCmdLine"
 *			The command line
 * 
 * @xxxx
 *
 */
void CTestFrameworkMain::StartTestingL(const TDesC& aCmdLine)
	{
	RunTestScriptL(aCmdLine);

	RSemaphore sem;
	TInt err = sem.OpenGlobal(KRecogSemaphoreName);
	if (err==KErrNone)
		{
		// Tell the recognizer thread that we're finished
		sem.Signal();
		sem.Close();
		}
	}
void CMultiThreadTestApp::ConstructL(CAppActive* aAO)
	{
	TInt error = iSyncSemaphoreOne.CreateGlobal(KSyncSemaphoreOne(), 0);
	if (error == KErrAlreadyExists || error == KErrNone)
		{
		iSyncSemaphoreOne.OpenGlobal(KSyncSemaphoreOne());
		}
	else
		{
		User::Leave(error);
		}
		
	error = iSyncSemaphoreTwo.CreateGlobal(KSyncSemaphoreTwo(), 0);
	if (error == KErrAlreadyExists || error == KErrNone)
		{
		iSyncSemaphoreTwo.OpenGlobal(KSyncSemaphoreTwo());
		}
	else
		{
		User::Leave(error);
		}		
	iActive = aAO;
	}
Пример #18
0
// -----------------------------------------------------------------------------
// RDosServer::StartServer
// Creates the server thread/process
// -----------------------------------------------------------------------------
EXPORT_C TInt RDosServer::StartServer() const
{
    API_TRACE_( "[DOSSERVER] RDosServer::StartServer()" );

    TInt ret(KErrNone);
	TRequestStatus status;
    // IPCv2: TSignal no longer used, but still passed to threadfunction as 
	// otherwise API change would be required.
	CDosServer::TSignal signal( status );

	// Create startup semaphore
	RSemaphore startupSemaphore;
	ret = startupSemaphore.CreateGlobal( KServerStartupSemaphoreName, 0 );

	if ( ret == KErrAlreadyExists )
		{
		// The server is starting up, but has not yet started 
		startupSemaphore.OpenGlobal( KServerStartupSemaphoreName );
		startupSemaphore.Wait(); // wait until the server has started up.
		startupSemaphore.Close();
		return ret;
		}

	// launch server thread (emulator) or process (Target platform)

	RProcess server;

	ret = server.Create( KDosServerExe, signal.Get(),
                       TUidType( KNullUid, KNullUid, KDosServerUid ),
                       EOwnerThread );

	if ( ret )
	{
		startupSemaphore.Close();
		return ret;
	}

	server.SetPriority(EPriorityHigh);

	server.Resume();
	server.Close();

	startupSemaphore.Wait();
	startupSemaphore.Close();

	return KErrNone;
}
Пример #19
0
static void RunL()
	{
	User::LeaveIfError(RThread::RenameMe(KTestProcGood));

	CActiveScheduler* s=new(ELeave) CActiveScheduler;
	CleanupStack::PushL(s);
	CActiveScheduler::Install(s);
	
	if(CmdLineOptionL(KLaunchServerCommandLineOption))
		{
		CTestServerGood::NewLC();
		}
		
	if(!CmdLineOptionL(KTestProcGoodNoRendevouz))
		{
		RProcess::Rendezvous(KErrNone);
		}

	if(CmdLineOptionL(KFailAfterRendevouzCommandLineOption))
		{
		User::Leave(KErrAbort);
		}
		
	_LIT(KTestGoodProcPanic, "Panic");
	if(CmdLineOptionL(KPanicCommandLineOption1))
		{
		User::Panic(KTestGoodProcPanic, KProcPanic);
		}

	if(CmdLineOptionL(KPanicCommandLineOption2))
		{
		User::Panic(KTestGoodProcPanic, KErrNone);
		}
	
	RSemaphore sem;
	TInt err = sem.OpenGlobal(KStartShmaTestProcGood);
	if(err == KErrNone)
		{
		sem.Signal();
		sem.Close();
		}
	
	CActiveScheduler::Start();

	CleanupStack::PopAndDestroy(2);
	}
Пример #20
0
// -----------------------------------------------------------------------------
// CSearchServer::ThreadFunctionL()
// Second stage startup for the server thread.
// -----------------------------------------------------------------------------
//
void CSearchServer::ThreadFunctionL()
	{
	// Construct active scheduler
    User::RenameThread(KSearchServerName); 
	CActiveScheduler* activeScheduler = new ( ELeave ) CActiveScheduler;
	CleanupStack::PushL(activeScheduler);

	// Install active scheduler
	CActiveScheduler::Install(activeScheduler);

	// Construct server
	CSearchServer* server = CSearchServer::NewLC();
	
    // Rename the thread.
           
    RProcess::Rendezvous(KErrNone);           

	// Signal client thread if started by such
	RSemaphore semaphore;
	TInt err = semaphore.OpenGlobal(KSearchServerSemaphoreName);
	if (KErrNone == err)
		{
		// Started by client
		semaphore.Signal();
		semaphore.Close();
		}
	else
		{
		if (KErrNotFound == err)
			{
			// Started by S60 starter
			}
		else
			{
			// Unknown error, leave
			User::Leave(err);
			}
		}

	// Start handling requests
	CActiveScheduler::Start();
	
	// Cleanup
	CleanupStack::PopAndDestroy( server );
	CleanupStack::PopAndDestroy( activeScheduler );
	}
Пример #21
0
GLDEF_C TInt EtelServerThread(TAny* /*anArg*/)
//
// The ETel Server Thread.
//
	{
	__UHEAP_MARK;
	LOGTEXT(_L8("----------New Log----------\015\012"));
	LOGTEXT(_L8("Entered ETel Server thread"));
	LOGTEXTREL(_L8("Entered ETel Server thread"));

	CTrapCleanup* pT;
	if ((pT=CTrapCleanup::New())==NULL)
		Fault(EEtelFaultCreateTrapCleanup);

	//
	// Start the scheduler and then the server
	//
	CTelScheduler* pScheduler = CTelScheduler::New();
	CTelServer* pServer=CTelServer::New();

	User::SetCritical(User::ENotCritical);
	RSemaphore s;
	TInt semRet=s.OpenGlobal(KETelSemaphoreName);

	if (semRet==KErrNone)
		{
		s.Signal();
		s.Close();
		}
	RLibrary lib;
	lib.Load(KEtelDLLName); // to ensure the access count on the library is always >0
										// while the ETel thread is running
	CTelScheduler::Start();
	LOGTEXT(_L8("ETel:\tScheduler has been stopped\n"));

	delete pT;
	delete pServer;
	delete pScheduler;

	LOGTEXT(_L8("ETel:\tAbout to exit ETel thread function\n"));
	LOGTEXTREL(_L8("ETel:\tAbout to exit ETel thread function\n"));
	__UHEAP_MARKEND;

	return(KErrNone);
	}
Пример #22
0
TInt StartupClock( TAny* ) 
    {
    DRMLOG( _L( "unipertar.exe: StartupClock" ) );
    TInt error = KErrNone;
    CTrapCleanup* trap = CTrapCleanup::New();
    
    // Check that memory allocation was successful.
    __ASSERT_ALWAYS( trap, User::Invariant() );
    
    DRMLOG( _L( "unipertar.exe: StartupClock: active scheduler" ) );

    CActiveScheduler* scheduler = new CActiveScheduler();
    
    __ASSERT_ALWAYS( scheduler, User::Invariant() );
    
    CActiveScheduler::Install( scheduler );
    
    // Reusing semaphore
    RSemaphore clientSem;
    __ASSERT_ALWAYS( !( clientSem.OpenGlobal( KDRMEngCommonSemaphore ) ), 
        User::Invariant() );
    
    error = StartClockServer( clientSem );
    
    if ( error ) {
        // Server creation failed. Release the semaphore.
        // In case of successful startup, CDRMClockServer
        // releases the semaphore.
        clientSem.Signal();
        clientSem.Close();
        }
    
    delete scheduler; 
    scheduler = NULL;
    
    delete trap;
    trap = NULL;
    
    DRMLOG2( _L( "unipertar.exe: StartupClock exits with %d" ), error );
    
    return error;
    }
Пример #23
0
void CPropertyObserver::RunL()
    {
    RSysMonSession sess;
    //Opens a session with System monitor in order to cancel the monitoring
    sess.OpenL();
	CleanupClosePushL(sess);
    sess.CancelMonitorSelfL();
   	CleanupStack::PopAndDestroy(&sess);

    //Signal that application will be closed
    RSemaphore sem;
    TInt err = sem.OpenGlobal(KStartShmaTestAppGood);
    if(err == KErrNone)
        {
        sem.Signal();
        sem.Close();
        }

    //Kill the current process
    User::Exit(KErrNone);
    }
Пример #24
0
// The server thread.
void CSoundStreamServer::ThreadFunctionL() {
	
	// start scheduler and server
	CActiveScheduler *pA=new CActiveScheduler;
	CleanupStack::PushL(pA);
	CActiveScheduler::Install(pA);

	CSoundStreamServer::NewLC();
	
	RSemaphore semaphore;
	User::LeaveIfError(semaphore.OpenGlobal(KSoundStreamServerSemaphoreName));

	// Semaphore opened ok
	semaphore.Signal();
	semaphore.Close();

	// start active scheduler
	CActiveScheduler::Start();

	CleanupStack::PopAndDestroy(2, pA);
}
Пример #25
0
/**
The method releases the access the RWindows object, which manages aScreenNo screen.
If there are no more clients (Symbian OS devices) for that window, it will be destroyed.
@param aScreenNo Screen number
*/
void RWindows::ReleaseWindow(TInt aScreenNo)
	{
	if(TheWinsWindowHandlers[aScreenNo] == NULL)
        {//The related TheWinsWindowHandlers[aScreenNo] is NULL, which means that the 
         //related RWindows object has been destroyed. Do nothing.
		return;
        }
	RSemaphore windowInUse;
    TBuf<32> screenSemaphoreName;
    ::CreateScreenSemaphoreName(aScreenNo, screenSemaphoreName);
	TInt ret = windowInUse.OpenGlobal(screenSemaphoreName,EOwnerThread);
    //The related semaphore does not exist, which means - all the clients, which have a shared
    //access to aScreenNo screen, do not use it anymore. It is safe to destroy the related
    //Windows OS window object.
	if (ret == KErrNotFound)
		{
		TheWinsWindowHandlers[aScreenNo]->Destroy();
		TheWinsWindowHandlers[aScreenNo] = NULL;
		}
	windowInUse.Close();
	}
Пример #26
0
TInt StartupNotifier( TAny* ) 
    {
    TInt error = KErrNone;
    CTrapCleanup* trap = CTrapCleanup::New();
    
    // Check that memory allocation was successful.
    __ASSERT_ALWAYS( trap, User::Invariant() );
    
    CActiveScheduler* scheduler = new CActiveScheduler();
    
    __ASSERT_ALWAYS( scheduler, User::Invariant() );
    
    CActiveScheduler::Install( scheduler );
    
    RSemaphore clientSem;
    error = clientSem.OpenGlobal( KDRMEngCommonSemaphore );
    if( error ) 
        {
    	  return error;
        }
    error = StartNotifierServer( clientSem );
    
    if ( error ) {
        // If errors didn't occur, signal has been sent.
        clientSem.Signal();
        clientSem.Close();
        }
    
    delete scheduler; 
    scheduler = NULL;
    
    delete trap;
    trap = NULL;
    
    // __ASSERT_ALWAYS( !error, User::Invariant() );
    
    return KErrNone;
    }
Пример #27
0
static void RunL()
	{
	User::LeaveIfError(RThread::RenameMe(KTestProcGood));

	CActiveScheduler* s=new(ELeave) CActiveScheduler;
	CleanupStack::PushL(s);
	CActiveScheduler::Install(s);
	
	if(CmdLineOptionL(KLaunchServerCommandLineOption))
		{
		CTestServerGood::NewLC();
		}
		
	if(!CmdLineOptionL(KTestProcGoodNoRendevouz))
		{
		RProcess::Rendezvous(KErrNone);
		}

	if(CmdLineOptionL(KFailAfterRendevouzCommandLineOption))
		{
		User::Leave(KErrAbort);
		}
		
	//Signalling the start of the application
	RSemaphore sem;
	TInt err = sem.OpenGlobal(KStartProcSignalSemaphore);
	RDebug::Print(_L("KStartProcSignalSemaphore Opened with %d"), err);
	
	if(err == KErrNone)
		{
		sem.Signal();
		sem.Close();
		}

	CActiveScheduler::Start();

	CleanupStack::PopAndDestroy(2);
	}
Пример #28
0
TInt CDcfRepSrv::Startup( void )
{
    TInt err = 0;
    TBool clientIsWaiting = EFalse;
    RSemaphore semaphore;

    CTrapCleanup* cleanupStack = CTrapCleanup::New();

    if (cleanupStack == NULL)
    {
        PanicServer(ECreateTrapCleanup);
    }

    // check if the client wants to be signaled that we are ready
    if ( semaphore.OpenGlobal(KDcfRepSemaphoreName) == KErrNone )
    {
        clientIsWaiting = ETrue;
    }

    TRAP(err, StartupL());

    // release client side waiting
    if (clientIsWaiting)
    {
        semaphore.Signal();
        semaphore.Close();
    }

    if (err != KErrNone)
    {
        PanicServer(ESrvCreateServer);
    }

    delete cleanupStack;
    cleanupStack = NULL;
    return KErrNone;
}
Пример #29
0
// -----------------------------------------------------------------------------
// SipCRServerMain::ThreadFunction
// -----------------------------------------------------------------------------
//
TInt SipCRServerMain::ThreadFunction (TAny* /*aNone*/)
	{
    TInt err = KErrNone;
    CTrapCleanup* cleanupStack = CTrapCleanup::New();
	if (!cleanupStack) 
        {
        PanicServer(ECreateTrapCleanup);
        }
	RSemaphore semaphore;
	err = semaphore.OpenGlobal(KSipClientResolverServerSemaphoreName);
    if (err != KErrNone)
        {
        PanicServer(ESrvCreateServer);
        }
    TRAP(err, ThreadFunctionL(semaphore));
    if (err != KErrNone)
        {
        semaphore.Signal();
        semaphore.Close();
        }

    delete cleanupStack;
    return err;
	}
LOCAL_C void LaunchClientProcessL()
	{
	__UHEAP_MARK;
	RProcess::Rendezvous(KErrNone);

    RSemaphore sem;
    User::LeaveIfError(sem.OpenGlobal(KEglStressTest));
    CleanupClosePushL(sem);

    //Access data passed from the main process
    TStressProcessInfo info;
    TPckg<TStressProcessInfo> pckgInfo(info);
    User::LeaveIfError(User::GetDesParameter(KMultiProcessSlot, pckgInfo));

    //Create RSgDriver and open the image
    RSgDriver driver;
    User::LeaveIfError(driver.Open());
    CleanupClosePushL(driver);

    RSgImage image;
    User::LeaveIfError(image.Open(info.iSgId));
    CleanupClosePushL(image);

    EGLDisplay display;
    EGL_LEAVE_NULL(display, eglGetDisplay(EGL_DEFAULT_DISPLAY));
    EGL_LEAVE_ERROR(eglInitialize(display, NULL, NULL));
    EGL_LEAVE_ERROR(eglBindAPI(EGL_OPENVG_API));

    //Initialise to remove arm compiler warnings
    EGLConfig config = 0;
    EGLContext context = EGL_NO_CONTEXT;
    EGLSurface surface = EGL_NO_SURFACE;

    if(info.iTestType == EStressRead)
        {
        TSgImageInfo sginfo;
        User::LeaveIfError(image.GetInfo(sginfo));

        //Create an independant pixmap surface on which to copy the vgimage 
        RSgImage image2;
        User::LeaveIfError(image2.Create(sginfo, NULL, NULL));
        CleanupClosePushL(image2);
        ChooseConfigAndCreateContextL(display, context, config, image2, KStressTestChildAppPanic, info.iAlphaPre);
        EGL_LEAVE_NULL(surface, CreatePixmapSurfaceL(display, config, image2, info.iAlphaPre)); 
        CleanupStack::PopAndDestroy(&image2);
        }
    else
        {
        ChooseConfigAndCreateContextL(display, context, config, image, KStressTestChildAppPanic, info.iAlphaPre);
        EGL_LEAVE_NULL(surface, CreatePixmapSurfaceL(display, config, image, info.iAlphaPre));       
        }

    EGL_LEAVE_ERROR(eglMakeCurrent(display, surface, surface, context));

    VGImage vgImage;
    GenerateVgImageL(display, &image, vgImage);

    /* Create and install the active scheduler */
    CActiveScheduler* sched = new(ELeave) CActiveScheduler;
    CActiveScheduler::Install(sched);
    CleanupStack::PushL(sched);

    TInt width = vgGetParameteri(vgImage, VG_IMAGE_WIDTH);
    VgLeaveIfErrorL();

    TInt height = vgGetParameteri(vgImage, VG_IMAGE_HEIGHT);
    VgLeaveIfErrorL();

    VGImageFormat format = static_cast<VGImageFormat>(vgGetParameteri(vgImage, VG_IMAGE_FORMAT));
    VgLeaveIfErrorL();

    TBool testPass = ETrue;

    CTReadWriteChild* painter = CTReadWriteChild::NewL(vgImage, width, height, info.iByteSize, format, info.iTestType, testPass);
    CleanupStack::PushL(painter);
    painter->After(TTimeIntervalMicroSeconds32(0));

    //Data access is synchronised from the main process
    sem.Wait();
    sched->Start();

    if(testPass == EFalse)
        {
		// Leave with a 'known' test error so that we can catch this particular failure 
        User::Leave(KTestStressUnexpectedPixelError);
        }
    
    CleanupStack::PopAndDestroy(5, &sem); //painter, sched, image, driver, sem
      
    __UHEAP_MARKEND;
    }