Exemple #1
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
    }
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;
	}
// ---------------------------------------------------------------------------
// StartServerL()  
//  Starts Fota Downlaod Interrupt Monitory server
// ---------------------------------------------------------------------------
TInt StartServerL()
    {
    FLOG(_L("StartServerLt Started"));
    TInt res = KErrNone;
    
    RProcess server;
    RSemaphore sem;
    res = sem.CreateGlobal(KFotaServerScem, EOwnerProcess);

    res=server.Create(KFotaServerName,KNullDesC);
    FLOG(_L("StartServerL-- create server error as %d"),res);
    if (res!=KErrNone)
        {       
        return res;
        }

    server.Resume();    // logon OK - start the server
    
    sem.Wait();
    sem.Close();
    server.Close();
    
    FLOG(_L("StartServerL-- server.ExitType() returns %d"),res);

    return res;
    }
void CSuplProxyPrivacySession::NewPrivacyRequest(const RMessage2& aMessage)
	{
	LBSLOG(ELogP1, "CSuplProxyPrivacySession::NewPrivacyRequest() Begin\n");

	TLbsNetSessionId sessionId;
	iPrivacyProtocol.GetNextSessionId(sessionId);

	TPckg<TUint32> pkgReqId(sessionId.SessionNum());
	TInt error = aMessage.Write(0,pkgReqId);
	if(error != KErrNone)
		{
		aMessage.Complete(error);
		return;
		}
	
	RSemaphore semaphore;
	error = semaphore.Open(aMessage, 3, EOwnerThread);
	if(error != KErrNone)
		{
		aMessage.Complete(error);
		return;
		}
	semaphore.Signal();
	semaphore.Close();

	PrivacyRequest(aMessage, sessionId.SessionNum());

	LBSLOG(ELogP1, "CSuplProxyPrivacySession::NewPrivacyRequest() End\n");
	}
/**
 * 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;
	}
void TestServerPanic()
	{
	TRequestStatus status;
	
	test_KErrNone(TheSemaphore.CreateLocal(0));
	
	RDebug::Printf("Main: start server");
	RThread serverThread;
	test_KErrNone(serverThread.Create(_L("server"), ServerThread, 4096, NULL, NULL));
	serverThread.Rendezvous(status);
	serverThread.Resume();
	User::WaitForRequest(status);
	test_KErrNone(status.Int());

	RDebug::Printf("Main: start client");
	RProcess clientProcess;
	test_KErrNone(clientProcess.Create(KMyName, _L("client")));
	clientProcess.Resume();
	clientProcess.Logon(status);
	User::WaitForRequest(status);
	test_KErrNone(clientProcess.ExitReason());
	test_Equal(EExitKill, clientProcess.ExitType());

	RDebug::Printf("Main: kick server");
	TheSemaphore.Signal();
	
	RDebug::Printf("Main: wait for server to exit");
	serverThread.Logon(status);
	User::WaitForRequest(status);
	test_KErrNone(serverThread.ExitReason());
	test_Equal(EExitKill, serverThread.ExitType());

	User::After(1);
	RDebug::Printf("Main: exit");
	}
// ----------------------------------------------------------------------------
// 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
		} )
Exemple #8
0
GLDEF_C TInt E32Main()
	{     
	CTrapCleanup::New();

	RWin32Stream::StartServer();	// arrange for access to Win32 stdin/stdout/stderr
	SpawnPosixServerThread();	// arrange for multi-threaded operation

	int argc=0;
	wchar_t** wargv=0;
	wchar_t** wenvp=0;


	__crt0(argc,wargv,wenvp);			// get args & environment from somewhere

#ifndef EKA2
	// Cause the graphical Window Server to come into existence
	RSemaphore sem;
	sem.CreateGlobal(_L("WsExeSem"),0);
	RegisterWsExe(sem.FullName());
#endif

	int ret=wmain(argc, wargv, wenvp);		// go

	// no need to explicitly delete the cleanup stack here as all memory used by
	// the process will be released by RProcess::Terminate(), called from inside exit().

	exit(ret);	// to get atexit processing, eventually terminates this process

	return(KErrNone);
	}
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;
	}
void CAlmSettingsServer::SignalL(void)
{
  RSemaphore semaphore;
  User::LeaveIfError(semaphore.OpenGlobal(KSettingsServerSemaphoreName));
  semaphore.Signal();
  semaphore.Close();
}
Exemple #11
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);
	}
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;
}
/**
* 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;
	}
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
static TInt StartLockServer()
    {
    TInt result;

    TFindServer findTimeServer(KCrashServerName);
    TFullName name;

	result = findTimeServer.Next(name);
	if (result == KErrNone)
        {
		// Server already running
		return KErrNone;
	    }

	RSemaphore semaphore;		
	result = semaphore.CreateGlobal(KCrashServerSemaphoreName, 0);
    if (result != KErrNone)
        {
        return  result;
        }

    result = CreateLockServerProcess();
    if (result != KErrNone)
        {
        return  result;
        }

	semaphore.Wait();
	semaphore.Close();       

    return  KErrNone;
    }
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);
		}
	}
LOCAL_C void DoTestsL()
    {
    
    // Initialisation
    MainTest.Start(_L("@SYMTESTCaseID:PIM-T-CONCURRENT-0001 T_Concurrent"));

    
    // Create active scheduler (to run active objects)
    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
    CleanupStack::PushL(scheduler);
    CActiveScheduler::Install(scheduler);

    // Create main thread object, child thread and synchnising semaphore.
    sem.CreateLocal(0);
    CMainThread * ptr = CMainThread::NewL();
    CleanupStack::PushL(ptr);
    ptr->LaunchChildThreadL();
	
	// Run all the tests
	while (currentStep <= ETestsEnd)
		{
		switch(currentStep)
			{
			case ETestCreate:
				// create the db in shared mode and add a contact. 
			    ptr->TestCreateDatabaseL();
			    ptr->TestAddContactL();
				break;
			case ETestOpen:
			 	// create the db in shared mode 
			    ptr->TestOpenDatabaseL();
			    ptr->TestAddContactL();
				break;
			case ETestReplace:
				// create the db in shared mode 
			    ptr->TestReplaceDatabaseL();
				ptr->TestAddContactL();
				break;
			case ETestsEnd:
				break;
			default:
				break;
			} // end of switch
			
			// Run the child thread and let it access the shared session.
		    ptr->ResumeChildThreadL();
		    sem.Wait();
		    ptr->CloseDatabaseSessionL();
		    currentStep++ ;
		} // end of while

    // Cleanup and close.
    sem.Close();
    CleanupStack::PopAndDestroy(ptr);
    CleanupStack::PopAndDestroy(scheduler);
    }
void CConcurrentDatabaseAccessBase::CloseSemaphore()
	{
	if (iSemaphoreOpen)
		{
		iSemaphoreSignal.Close();
		iSemaphoreWait.Close();
		}

	iSemaphoreOpen = EFalse;
	}
void DoTestsL()
	{
    MainThreadCrS.CreateLocal(0);
    
    TheTest.Start(_L(" @SYMTestCaseID:PDS-EFM-CT-4058 Restore Query and Modification Response"));
    TestRestoreResponseL();
    
    MainThreadCrS.Close();

	}
static void SignalTestExe()
	{
	_LIT(KSchSemaphoreName, "SCHMinimalTaskHandler");
	RSemaphore sem;
	TInt ret = sem.OpenGlobal(KSchSemaphoreName);
	if (ret == KErrNone)
		{
		sem.Signal();
		sem.Close();
		}
	}
Exemple #20
0
/* Free the semaphore */
void SDL_DestroySemaphore(SDL_sem *sem)
{
	if ( sem ) 
	{
    RSemaphore sema;
    sema.SetHandle(sem->handle);
	sema.Signal(sema.Count());
    sema.Close();
    delete sem;
	sem = NULL;
	}
}
Exemple #21
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);
	}
/**
 *
 * 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();
		}
	}
Exemple #23
0
/* Create a semaphore */
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{
   RSemaphore s;
   TInt status = CreateUnique(NewSema, &s, &initial_value);
   if(status != KErrNone)
	 {
			SDL_SetError("Couldn't create semaphore");
	}
    SDL_semaphore* sem = new /*(ELeave)*/ SDL_semaphore;  
    sem->handle = s.Handle();
	sem->count = initial_value;
	return(sem);
}
Exemple #24
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);
	}
Exemple #25
0
TInt StartThread() {
	TInt result;

	TFindServer findSoundServer(KSoundStreamServerName);
	TFullName name;

	result = findSoundServer.Next(name);
	if (result == KErrNone) {
		// Server already running
		return KErrNone;
	}

	RSemaphore semaphore;
	result = semaphore.CreateGlobal(KSoundStreamServerSemaphoreName, 0);

	if (result != KErrNone) {
		return result;
	}

	RThread thread;

	result=thread.Create(
		KSoundStreamServerName,   // create new server thread
		CSoundStreamServer::ThreadFunction, // thread's main function
		KDefaultStackSize,
		NULL, // share heap with current thread
		&semaphore // passed as TAny* argument to thread function
		);

	if (result != KErrNone) {
		return result;
	}

    thread.SetPriority(EPriorityRealTime); // set thread priority to realtime

	thread.Resume(); // start it going
	thread.Close(); // we're no longer interested in the other thread

	// notify the kernel that a server has started.
	#if defined (__WINS__)
	UserSvr::ServerStarted();
	#endif
	
	// wait for signal from other thread
    semaphore.Wait();
	semaphore.Close();

	return KErrNone;
}
// -----------------------------------------------------------------------------
// Function StartClockServer().
// This function starts the actual server under TRAP harness and starts
// waiting for connections. This function returns only if there has been
// errors during server startup or the server is stopped for some reason.
// 
// Returns: TInt: Symbian OS error code.
// -----------------------------------------------------------------------------
LOCAL_C TInt StartClockServer( RSemaphore& aClientSem ) 

    {
    TInt error = KErrNone;
    CDRMClockServer* server = NULL;

    TUint8 count = 0;

    do 
    {
       DRMLOG2( _L( "unipertar.exe: StartClockServer: %d" ), error );
       
       ++count;
       
       TRAP( error, ( server = CDRMClockServer::NewL() ) );
       
       if ( error ) 
       {
          User::After( TTimeIntervalMicroSeconds32(KWaitingTime) );
       }
       
    } while( error && ( count <= KMaxStartTries ) );
    
    if( error ) 
    {
        // Failed
        return error;
        }
       
    // Release the semaphore...
    aClientSem.Signal();
    
    // and close it. Otherwise there will be an unused handle to the semaphore
    // until the phone is switched off.
    aClientSem.Close();
    
    DRMLOG( _L( "unipertar.exe: StartClockServer: starting..." ) );

    // Start waiting for connections
    CActiveScheduler::Start();
    
    // Dying.
    
    DRMLOG( _L( "unipertar.exe: StartClockServer: dying" ) );

    delete server;
    
    return KErrNone;
    }
bool_t SemaphoreWait(void* Handle,int Tick)
{
	RSemaphore p;	
	p.SetHandle((int)Handle);
    if (Tick>=0)
    {
#if defined(SYMBIAN90)
        return p.Wait(Tick*1000) == KErrNone;
#else
        //!!! todo 
#endif
    }
    p.Wait();
    return 1;
}
void StartAlmSettingsServerL(void)
{
  TFindServer find(KSettingsServerName);
  TFullName name;
  if(find.Next(name)==KErrNone) User::Leave(KErrGeneral);
  RSemaphore semaphore;
  User::LeaveIfError(semaphore.CreateGlobal(KSettingsServerSemaphoreName,0));
  CleanupClosePushL(semaphore);
  RThread thread;
  User::LeaveIfError(thread.Create(KSettingsServerName,CAlmSettingsServer::ThreadFunction,KDefaultStackSize,KMinHeapSize*16,KMinHeapSize*16,NULL));
  CleanupClosePushL(thread);
  thread.Resume();
  semaphore.Wait();
  CleanupStack::PopAndDestroy(2); //thread,semaphore
}
TInt TestThreadL(void*)
    {
        __UHEAP_MARK;
        
        CTrapCleanup* tc = CTrapCleanup::New();
        RFeatureControl rfc;
        TTEST2( rfc.Connect(), KErrNone );
        
        // During restore, feature manager server should be responsive and return KErrServerBusy for write request 
        TInt err = rfc.EnableFeature( TUid::Uid(0x00000001) );
        TTEST2(err, KErrServerBusy);
		
        // During restore, feature manager server should be responsive and NOT return KErrServerBusy for read request
		err = rfc.FeatureSupported( TUid::Uid(0x00000001) );
		TTEST(err != KErrServerBusy);
		
        rfc.Close();
        featMgrIsResponsive = ETrue;
        RDebug::Print(_L("+++:TestThread: Query and Modification completed\r\n"));
        MainThreadCrS.Signal();
        delete tc;
        
        __UHEAP_MARKEND;
        
        return KErrNone;
    }
/**
@SYMTestCaseID          PDS-EFM-CT-4058
@SYMTestCaseDesc        Querying and modifying a feature during restore operation. 
                        Verify that a response is returned from the server during restore.
@SYMTestPriority        High
@SYMTestActions         Start simulating restore operation
                        Create a thread that will:
                        Modify a feature and verify that a response (KErrServerBusy) is received 
                        Query a feature and verify that a response is received (doesn't matter what the result is)
                        The thread should finished in less than 2 seconds.
                        Otherwise the test fail.          
@SYMTestExpectedResults Test must not fail
@SYMREQ                 
*/  
void TestRestoreResponseL()
    {
        _LIT(KThreadName, "RstTh");
        featMgrIsResponsive = EFalse;
        
        CFeatMgrBURSim* simulate = CFeatMgrBURSim::NewLC();
        RThread testThread;
        TRequestStatus testStatus;
        CleanupClosePushL( testThread );
        
        //Needs to ensure server is started before simulating backup operation
        RFeatureControl rfc;
        TTEST2( rfc.Connect(), KErrNone ); //This will start the server if not already started
        rfc.Close();
        
        simulate->Simulate_CheckRegFileL();
        
        // Simulate a restore
        RDebug::Print(_L("Simulating Restore of FeatMgr\r\n"));
        simulate->Simulate_StartRestoreL();

        TEST2( testThread.Create(KThreadName, &TestThreadL, 0x2000, 0x1000, 0x10000, NULL, EOwnerProcess), KErrNone );
        testThread.Logon(testStatus);
        TEST2( testStatus.Int(), KRequestPending );
        testThread.Resume();
        // Wait for 1.5 second for the query thread to finish. 
        RDebug::Print(_L("+++:MainThread: Wait for query and modification completion...\r\n"));
        MainThreadCrS.Wait(threadTimeout);
        // If query is responsive within the 1.5 second frame the following check should pass.
        TEST (featMgrIsResponsive);
        simulate->Simulate_EndRestoreL();
        
        CleanupStack::PopAndDestroy(&testThread);
        CleanupStack::PopAndDestroy(simulate);
    }