示例#1
0
void CCmdSetpriority::NewThread(TInt aHandle)
	{
	if (aHandle == KErrNotSupported)
		{
		PrintError(KErrNotSupported, _L("Kernel was not compiled with __DEBUGGER_SUPPORT__, can't get thread creation notifications."));
		Complete(aHandle);
		}
	else if (aHandle < 0)
		{
		PrintError(aHandle, _L("Failed to get new thread notification, or couldn't open handle to thread."));
		Complete(aHandle);
		}
	else
		{
		RThread thread;
		thread.SetHandle(aHandle);
		TFullName name(thread.FullName());
		TInt priority = 0;
		TPckg<TThreadKernelInfo> pkg(iThreadInfo);
		TInt err = iMemAccess.GetObjectInfoByHandle(EThread, RThread().Id(), aHandle, pkg);
		if (!err)
			{
			priority = iThreadInfo.iThreadPriority;
			}

		TUint tid = thread.Id();
		Printf(_L("New thread id %u name %S priority adjusted to %d\r\n"), tid, &name, priority);
		thread.Close();
		}
	}
/**
Gives the calling thread an exclusive access to some SQLITE shared resource(s).
The calling thread becomes a mutex owner.
If the mutex is already locked by another thread, the calling thread will block until 
the other thread unlocks the mutex.
TSqlite3SymbianMutex::Lock() can be called by the mutex owning thread more than once, even if the mutex is already locked.
*/
void TSqlite3SymbianMutex::Lock()
	{
	iMutex.Wait();
	RThread currThread;
	iOwnerThreadId = currThread.Id();
	++iLockCounter;
	}
// -----------------------------------------------------------------------------
// TMSCallServer::StartThreadL
//
// -----------------------------------------------------------------------------
//
void TMSCallServer::StartThreadL(TMSCallServerStartParam& aStart)
    {
    TRACE_PRN_FN_ENT;

    CActiveScheduler* sched = new (ELeave) CActiveScheduler;
    CleanupStack::PushL(sched);

    CActiveScheduler::Install(sched);
    TMSCallServer* server = TMSCallServer::NewL(aStart.iTMSServer);
    CleanupStack::PushL(server);

    //Rename tmscall server name
    RThread tmscallServerThread;
    TThreadId threadId;
    TName name;
    name.Append(KTMSCallServerName);
    threadId = tmscallServerThread.Id();
    name.AppendNum(threadId.Id(), EHex);
    //We are ignoring the error code returned from User::RenameThread
    //as it is not important here, may be for profiling
    User::RenameThread(name);

    aStart.iTMSCallServerHandle = server->Server();
    // Sync with the client and enter the active scheduler
    RThread::Rendezvous(KErrNone);
    sched->Start();

    CleanupStack::PopAndDestroy(server); // server
    CleanupStack::PopAndDestroy(sched); // sched

    TRACE_PRN_FN_EXT;
    }
LOCAL_C void Test1()	
//
//	This test is only called by default drive
//	Test OpenFileScan			
//
	{
	test.Next(_L("Scan for open files - one session only"));

	RFile file1,file2,file3;
	TFileName fn;
	fn = _L("Z:\\TEST\\T_FSRV.CPP");
	fn[0] = gExeFileName[0];
	TInt r=file1.Open(TheFs,fn,EFileRead|EFileShareReadersOnly);
	test(r==KErrNone);
	fn = _L("Z:\\TEST\\T_FILE.CPP");
	fn[0] = gExeFileName[0];
	r=file2.Open(TheFs,fn,EFileRead);
	test(r==KErrNone);
	fn = _L("Z:\\TEST\\T_FSRV.CPP");
	fn[0] = gExeFileName[0];
	r=file3.Open(TheFs,fn,EFileRead|EFileShareReadersOnly);
	test(r==KErrNone);
	
	CFileList* list;
	TOpenFileScan fileScan(TheFs);
	fileScan.NextL(list);

	if (gRunByBatch)
		{
		test(list!=NULL);
		test(list->Count()==1);
		TEntry entry=(*list)[0];
		test(entry.iName.FindF(_L(".BAT"))>=0);
		delete list;
		fileScan.NextL(list);
		}

	test(list!=NULL);
	TInt count=list->Count();
	test(count==3);
	TEntry entry=(*list)[0];
	test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
	entry=(*list)[1];
	test(entry.iName.FindF(_L("T_FILE.CPP"))>=0);
	entry=(*list)[2];
	test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
	TThreadId threadId=fileScan.ThreadId();
	RThread current;
	TThreadId currentId=current.Id();
	test(threadId==currentId);
	delete list;

	fileScan.NextL(list);
	test(list==NULL);

	file1.Close();
	file2.Close();
	file3.Close();
	}
// ----------------------------------------------------------------------------
// The thread ID of the client thread
// ----------------------------------------------------------------------------
//
TThreadId CMPXPlaybackSession::ClientIdL(const RMessage2& aMessage)
    {
    RThread t;
    aMessage.ClientL(t);
    TThreadId tid=t.Id();
    t.Close();
    return tid;
    }
示例#6
0
void CPropertyObserver::ConstructL()
        {
        RThread t;
        RDebug::Print(_L("Property init, thread %d"),t.Id().Id());
        User::LeaveIfError( iProperty.Attach( iUid, iKey ) );
        CActiveScheduler::Add(this);
        // initial subscription and process current property value
        RunL();
        }
/**
   TODO XL
   Auxiliary function for TestCaseID TAppLangFrenchSTARTER-doTestStepL
  
   This method creates an active object of class CMessageActive and adds it to
   the active scheduler.
  
 */
CMessageActive3* CMessageActive3::NewL()
	{
	CMessageActive3*	theMessage = new CMessageActive3;
    CActiveScheduler::Add(theMessage);
	
	RThread	thread;
	theMessage->iID = thread.Id();
	return theMessage;
	}
/**
Unlocks the mutex. If TSqlite3SymbianMutex::Lock() was called more than once by the owning thread, then the number of 
TSqlite3SymbianMutex::Unlock() calls must eventually match the number of TSqlite3SymbianMutex::Lock() calls.
If there are thread(s) blocked on TSqlite3SymbianMutex::Lock(), after the mutex gets unlocked one of the waiting threads
will be able to lock the mutex and get an exclusive access to the protected resource(s).

@panic Sqlite 31 If the lock counter is <= 0.
@panic Sqlite 32 If Unlock() is called by a thread that is not the current mutex owner.
*/
void TSqlite3SymbianMutex::Unlock()
	{
	__SQLITEASSERT_ALWAYS(iLockCounter > 0, ESqlitePanicMutexLockCounter);
#ifdef _DEBUG
	RThread currThread;	
	__SQLITEASSERT(iOwnerThreadId == currThread.Id(), ESqlitePanicMutexOwner);
#endif
	--iLockCounter;
	iMutex.Signal();
	}
TMMFDescriptorParams SetDescriptor( TPtr8* aDescriptor )
{
	RThread thread;
	TMMFDescriptorParams params;

	params.iDes = aDescriptor;			
	params.iDesThreadId = thread.Id(); // This thread

	return params;
}
示例#10
0
void CListsStep::ListThreadsL()
/**
 * @return void
 * This checks the threads are listed correctly and the returned values make sense
 */
	{
	INFO_PRINTF1(_L("Lists Test Suite: ListThreads") );

	if (TestStepResult()==EPass)
		{

		RThreadPointerList threadList;
		TCleanupItem cleanupThreadList(CTe_coredumpserverSuite::CleanupPluginList, (TAny*)&threadList);
		CleanupStack::PushL(cleanupThreadList);

		TRAPD( ret, iSess.GetThreadsL( threadList ) );
		if( KErrNone != ret )
			{
			SetTestStepResult(EFail);
			ERR_PRINTF2(_L("Error %d from iSess.GetThreadsL()"), ret);
			return;
			}

		if( threadList.Count() == 0 )
			{
			SetTestStepResult(EFail);
			ERR_PRINTF1(_L("Error : GetThreadsL() returned empty list") );
			return;
			}
		else
			{
			RThread thisThread;
			TInt i;
			for( i=0; i < threadList.Count(); i++ )
				{
				if( threadList[i]->Id() == thisThread.Id() )
					{
					break;
					}
				}

			if( i == threadList.Count() )
				{
				SetTestStepResult(EFail);
				ERR_PRINTF1(_L("Error : This thread could not be found in GetThreadsL() list/n") );
				return;
				}
			}

		CleanupStack::PopAndDestroy();		

		}
	}
CThreadOwner::CStopWaiter::CStopWaiter(CThreadAdmin& aAdmin, 
                                       CThreadOwner::ThreadData & threadData)
   : CActive(EPriorityStandard), iAdmin(aAdmin)
{
   CActiveScheduler::Add(this);
   iStatus = KRequestPending;
   SetActive();

   threadData.stopNowStatus = &iStatus;
   RThread thisThread;
   threadData.stopNowStatusThread = thisThread.Id();
   thisThread.Close();
}
示例#12
0
/**
Initialises access to the DF_EAP.  This will ensure the aAID and
aEapType given in the RMobileSmartCardEap::Open() exist and are
accessible.  If for any reason the sub-session is inaccessible, the
client can request a notification for state changes using
RMobileSmartCardEap::NotifyEapMethodAccessStatusChange().

@param aReqStatus Returns the result code after the asynchronous call
                  completes.  Successful completion is only achieved
                  when the client is the first to request
                  initialisation on this sub-session.
                  KErrInUse will be returned if another
                  RMobileSmartCardEap instance successfully achieved
                  initialisation first.
                  Any other error code returned as request completion,
                  suggests another problem in the system and the client
                  must call RMobileSmartCardEap::Close() or
                  RMobileSmartCardEap::ReleaseEapMethod() at some
                  point, to allow other clients to use this same
                  <AID,EapType> sub-session.
@see RMobileSmartCardEap::Open()
@see RMobileSmartCardEap::NotifyEapMethodAccessStatusChange()

@capability ReadDeviceData
@capability NetworkControl

@publishedPartner
@released
*/
EXPORT_C void RMobileSmartCardEap::InitialiseEapMethod(TRequestStatus& aReqStatus)
	{
	__ASSERT_ALWAYS(iMmPtrHolder != NULL, PanicClient(EEtelPanicNullHandle));

	if (!iOwnsEapMethodLock)
		{
		TInt ret = KErrNone;

		TInt semHandle = SendReceive(EEtelGlobalKernelObjectHandle);

		if(semHandle > 0)
			{
			ret = iSemaphore.SetReturnedHandle(semHandle); // although this will take an error as handle, best to specify our own explicit KErrBadHandle in the following else.
			}
		else
			{
			ret = KErrBadHandle;
			}

		if (ret != KErrNone)
			{
			TRequestStatus* status1 = &aReqStatus;
			User::RequestComplete(status1, ret);
			return;
			}

		ret = iSemaphore.Wait(10);
		if (ret == KErrTimedOut)
			{
			TRequestStatus* status2 = &aReqStatus;
			User::RequestComplete(status2, KErrInUse);
			return;
			}
		else if (ret != KErrNone)
			{
			TRequestStatus* status3 = &aReqStatus;
			User::RequestComplete(status3, ret);
			return;
			}

		iOwnsEapMethodLock = ETrue;
		}

	RThread ownerThread;
	TThreadId ownerThreadId = ownerThread.Id();

	iMmPtrHolder->iOwnerThreadId = ownerThreadId;
	TPtrC8& ptr1 = iMmPtrHolder->SetC(CMobileSmartCardEapPtrHolder::ESlot1InitialiseEapMethod, iMmPtrHolder->iOwnerThreadId);

	Set(EMobileSmartCardEapInitialiseEapMethod, aReqStatus, ptr1);
	}
void CFlushActive::Flush()
    {
    RThread currentContext;
    if (currentContext.Id() == iRunLContext.Id())
        {
        // The same context so cannot be running concurrently with CMD5Active::RunL() so safe to drain buffer queue
        iBufferHandler.FlushHeaders();
        return;
        }
    
    // Different thread to the one in which the Active objects are running,
    TRequestStatus* selfStatus = &iStatus;
    iRunLContext.RequestComplete(selfStatus, KErrNone);
    iWaitSemaphore.Wait();
    }
void CTContentUpdateReceiver::ContentUpdated(const TSurfaceId& aId, 
				TInt aBuffer, 
				const TRegion* aRegion, 
				TRequestStatus* aStatusAvailable, 
				TRequestStatus* aStatusDisplayed, TUint32* aTimeStamp, 
				TRequestStatus* aStatusDisplayedXTimes, TInt* aDisplayedXTimes)
	{
	(TAny)&aId;
	(TAny)aBuffer;
	(TAny)aRegion;
	
	iLock.Wait();
	if(iStop)
		{
		if(aStatusAvailable)
			{
			User::RequestComplete(aStatusAvailable, KErrDied);
			}
		if(aStatusDisplayed)
			{
			User::RequestComplete(aStatusDisplayed, KErrDied);
			}
		if(aStatusDisplayedXTimes)
			{
			User::RequestComplete(aStatusDisplayedXTimes, KErrDied);
			}
	    iLock.Signal();
		return;
		}
	
	RThread thread;
	iThreadId = thread.Id();
	
	if(aStatusAvailable)
		{
		Add(aStatusAvailable, EReqAvailable);
		}
	if(aStatusDisplayed)
		{
		Add(aStatusDisplayed, EReqDisplayed, 0, aTimeStamp);
		}
	if(aStatusDisplayedXTimes)
		{
		Add(aStatusDisplayedXTimes, EReqDisplayedXTimes, *aDisplayedXTimes);
		}
    iLock.Signal();
	}
// ---------------------------------------------------------------------------
// Starts monitoring thread
// ---------------------------------------------------------------------------
//
TInt CSensrvThreadMonitor::StartMonitoring(const RThread& aThread)
    {
    COMPONENT_TRACE( ( _L( "Sensor Server - CSensrvThreadMonitor::StartMonitoring()" ) ) );

    TInt err(KErrNone);

    if (aThread.Handle())
        {
        // If for some reason old iThread is still active, kill it.
        if ( (iThread.Handle()) && 
             (iThread.Handle() != RThread().Handle()) )
            {
            ERROR_TRACE( ( _L( "Sensor Sever - CSensrvThreadMonitor::StartMonitoring - ERROR: Old thread was still active, killing it." ) ) );
            iThread.LogonCancel(iStatus);
            iThread.Terminate(KErrCancel);
            iThread.Close();
            }
        
        // Old cleanuptimer needs to be deleted
        delete iCleanupTimer;
        iCleanupTimer = NULL;
        
        err = iThread.Open(aThread.Id());
        
        if (err == KErrNone)
            {
            iThread.Logon(iStatus);
            SetActive();

#if defined (COMPONENT_TRACE_FLAG) || defined(ERROR_TRACE_FLAG)
            iThreadName = iThread.Name();
#endif
            }
        }
    else
        {
        ERROR_TRACE( ( _L( "Sensor Server - CSensrvThreadMonitor::StartMonitoring - ERROR: NULL handle" ) ) );
        err = KErrBadHandle;
        }
    
    COMPONENT_TRACE( ( _L( "Sensor Server - CSensrvThreadMonitor::StartMonitoring - return %d" ), err ) );
   
    return err;
    }
示例#16
0
void LockEnter(void* Handle)
{
	lock_t *lock = (lock_t *)Handle;
    if (lock)
    {
        RThread current;
        TUint currentId = current.Id();
        if (lock->Thread == currentId)
            ++lock->Counter;
        else
        {
	        RMutex p;
	        p.SetHandle(lock->Handle);
	        p.Wait();
            assert(lock->Counter==0);
            lock->Counter = 1;
            lock->Thread = currentId;
        }
    }
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
//
TInt CPolicyClientRequestHandler::InsertClient(const RMessage2& aMessage)
	{
	
	TInt err = KErrNone;
	
	CPolicyEventReq* req = new CPolicyEventReq();
	if (!req)
		{
		return KErrNoMemory;
		}

	// Getting the client ID and storing it.	
	RThread client;
	err = aMessage.Client(client);
	if( err != KErrNone )
		{
		delete req;
		return err;
		}
	req->iClientId = client.Id();
	client.Close();
	
    err = iControlPolicyClients.Append(req);
    if( err == KErrNone )
    	{
		// Requesting all policies from the policy handler.
        err = iParent->GetAllControlPolicies( req->iOriginalControlPolicies );
		if( err == KErrNotFound )
			{
			// If no polices found, store message for later.
			req->iMessage = aMessage;
			return err;
			} 
        err = req->TotalPolicyCount();
    	}
    else
        {
        delete req;
        }
    return err;
	}
示例#18
0
/**
	@SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0055-0001
  
	@SYMPREQ PGM027
  
	@SYMTestCaseDesc Tests FindWindowGroupIdentifier API. 
   
	@SYMTestPriority 1 
  
	@SYMTestStatus Implemented
   
	@SYMTestActions Create windows session and call FindWindowGroupIdentifier \n
	with different thread Id's both with valid thread ids and in valid thread id's.
	
	@SYMTestExpectedResults Should run properly.

 */	
void CTTSprite::FindWindowGroupThreadTestsL()	
	{
	RThread proc;
	TInt ident;
	TUint64 id=proc.Id();
	RWsSession ws1;
	User::LeaveIfError(ws1.Connect());
	CleanupClosePushL(ws1);
	//Positive test for FindWindowGroupIdentifier
	ident=ws1.FindWindowGroupIdentifier(0,id);
	TEST(ws1.SetWindowGroupOrdinalPosition(ident,0)==KErrNone);
	TEST(ws1.SetWindowGroupOrdinalPosition(ident,1)==KErrNone);
	//Negative test for FindWindowGroupIdentifier
    TInt ret=ws1.FindWindowGroupIdentifier(0,id+200);
	TEST(ret==KErrNotFound);
	#if defined __WINS__ || defined __WINSCW__
	ret=ws1.FindWindowGroupIdentifier(0,-200);
	TEST(ret==KErrNotFound);
	#endif//defined __WINS__ || defined __WINSCW__
	CleanupStack::PopAndDestroy(1, &ws1);
	ws1.Close();
	}	
void CSenUnderTakerWaiter::RunL()
    {
    if(iStatus == KErrDied)
        {
        RThread th;
        th.SetHandle(iDyingThreadNumber);
        TFullName name = th.FullName();
        TExitType type = th.ExitType();

        
        if(iDispatcherThreadID == th.Id())
            {
            //Notifies client that thread is died. Client has to restart the 
            //connection here.In this case client has to create new SC object.
            if(type == EExitKill)
                {
                if(iSenServiceConnectionImpl)
                    {
                    iSenServiceConnectionImpl->iErrorNumber = EExitKill;
                    iSenServiceConnectionImpl->iTxnId = -1;    
                    iSenServiceConnectionImpl->HandleMessageFromChildAOL(iStatus.Int());
                    }
                }
            else    // panic
                {
                TExitCategoryName categ = th.ExitCategory();
                if(iSenServiceConnectionImpl)
                    {
                    iSenServiceConnectionImpl->iErrorNumber = EExitPanic;
                    iSenServiceConnectionImpl->iTxnId = -1;
                    iSenServiceConnectionImpl->HandleMessageFromChildAOL(iStatus.Int());
                    }
                }
            }
        th.Close();
        StartWaiter();
        }           
    }
示例#20
0
// -----------------------------------------------------------------------------
// CTFAStifTestLog::ConstructL
// -----------------------------------------------------------------------------
void CTFAStifTestLog::ConstructL( void )
    {
    TFileName fileName;
    TTime time;
    time.HomeTime();
    TDateTime dateTime = time.DateTime();
    RThread thread;
#ifdef __LOG_HTML__
    _LIT( KSuffix, "html" );
#else
    _LIT( KSuffix, "txt" );
#endif
    fileName.Format( _L( "%02d%02d%02d_%02d%02d%02d_%x.%S" ), 
        dateTime.Year() - 2000, dateTime.Month() + 1, dateTime.Day() + 1, 
        dateTime.Hour(), dateTime.Minute(), dateTime.Second(), 
        (TUint)thread.Id(), &KSuffix );
    iLogger = CStifLogger::NewL( _L( "c:\\logs\\testframework\\" ), fileName,
        CStifLogger::ETxt, CStifLogger::EFile, ETrue, EFalse, EFalse, EFalse, EFalse );
    iOverflowHandler = new ( ELeave ) TTFAOverflowHandler;
#ifdef __LOG_HTML__
    iLogger->Log( _L8( "<html><head><title>TFA Log</title></head>\r\n<body>\r\n" ) );
#endif
    }
示例#21
0
void CCmdUndertaker::ProcessHandle(TInt aDeadThreadHandle)
	{
	RThread deadThread;
	deadThread.SetHandle(aDeadThreadHandle);
	TFullName name(deadThread.FullName());
	TExitType type = deadThread.ExitType();
	if (type != EExitKill || deadThread.ExitReason() != 0 || iAll)
		{
		Write(_L("Thread "));
		Write(name);
		Printf(_L(" (tid=%d) "), (TUint)deadThread.Id());
		}

	if (type == EExitPanic)
		{
		TExitCategoryName cat = deadThread.ExitCategory();
		Printf(_L("panicked with %S %d\r\n"), &cat, deadThread.ExitReason());
		}
	else if (type == EExitTerminate)
		{
		Printf(_L("terminated with reason %d\r\n"), deadThread.ExitReason());
		}
	else if (deadThread.ExitReason() != 0)
		{
		// We'll consider a kill with non-zero exit code as counting as abnormal
		Printf(_L("killed with reason %d\r\n"), deadThread.ExitReason());
		}
	else if (iAll)
		{
		Printf(_L("exited cleanly\r\n"));
		}
		
	if (!iLeakThreads)
		{
		deadThread.Close();
		}
	}
示例#22
0
EXPORT_C TThreadId CSDL::CallMainL(const TMainFunc& aFunc, TRequestStatus* const aStatus, const CDesC8Array* const aArg, TInt aFlags, TInt aStackSize)
    {
    ASSERT(gEpocEnv != NULL);
    gEpocEnv->iMain = aFunc;
    const TBool args = aArg != NULL;
    
    if(gEpocEnv->iArgv != NULL)
    	User::Leave(KErrAlreadyExists);
    
    gEpocEnv->iArgc = args ? aArg->Count() + 1 : 0;
    gEpocEnv->iArgv = (char**) User::AllocL(sizeof(char*) * (gEpocEnv->iArgc + 2));  
      
    TInt k = 0;
    const TFileName processName = RProcess().FileName();
    const TInt len = processName.Length();
    gEpocEnv->iArgv[k] = (char*) User::AllocL(len + 1);
    Mem::Copy(gEpocEnv->iArgv[k], processName.Ptr(), len);
    gEpocEnv->iArgv[k][len] = 0;
      
    for(TInt i =  0; args && (i < aArg->Count()); i++)
        {
        k++;
        const TInt len = aArg->MdcaPoint(i).Length();
        gEpocEnv->iArgv[k] = (char*) User::AllocL(len + 1);
        Mem::Copy(gEpocEnv->iArgv[k], aArg->MdcaPoint(i).Ptr(), len);
        gEpocEnv->iArgv[k][len] = 0;
        }
        
    gEpocEnv->iArgv[k + 1] = NULL;
    
   
    if(aFlags & CSDL::ERequestResume)
        {
        gEpocEnv->iEpocEnvFlags |= EpocSdlEnvData::EResumeNeeded;   
    	}    
    
    gEpocEnv->iEventQueue->ConstructL();
    gEpocEnv->iAppSrv->ConstructL();
    
    gEpocEnv->iStackSize = aStackSize;
    
    if(EnvUtils::IsOwnThreaded())
		{  
    	RThread thread;
    	User::LeaveIfError(thread.Create(KSDLMain, DoMain, aStackSize, NULL, NULL));
    
   	 	if(aStatus != NULL)
    		{
    		thread.Logon(*aStatus);
    		}
 
    	gEpocEnv->iId = thread.Id();
    	thread.SetPriority(EPriorityLess);
    	if((aFlags & CSDL::ERequestResume) == 0)
        	{
        	thread.Resume();
       	 	}
    	thread.Close();
		}
	else
		{
		gEpocEnv->iCaller = CIdle::NewL(CActive::EPriorityIdle); //MUST!
		
		if((aFlags & CSDL::ERequestResume) == 0)
		    {
		    gEpocEnv->iCaller->Start(TCallBack(DoMain));
		    }
		
		gEpocEnv->iCallerStatus = aStatus;
		if(aStatus != NULL)
			*aStatus = KRequestPending;
		gEpocEnv->iId = RThread().Id();
		RThread().SetPriority(EPriorityLess);
		}
    return gEpocEnv->iId;
    }
CTContentUpdateReceiver::CTContentUpdateReceiver(TInt aScreen) :
	iScreen(aScreen), iVisible(ETrue)
	{
	RThread thread;
	iReceiverThreadId = thread.Id();
	}
示例#24
0
Uint32 SDL_ThreadID(void)
    {
    RThread current;
    const TThreadId id = current.Id();
	return id;
    }
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
TInt CPolicyClientRequestHandler::RequestPolicy( const RMessage2& aMessage )
	{
	TInt err = KErrNone;
	CPolicyEventReq* req = NULL;
	
	RThread client;
	err = aMessage.Client( client );
	if( err != KErrNone )
		{
		client.Close();
		return err;
		}
		
	TThreadId currClient = client.Id();
	client.Close();
	
	TInt clientCount = iControlPolicyClients.Count();
	for( TInt i = 0; i < clientCount; i++ )
		{
		req = iControlPolicyClients[i];
		if(req->iClientId == currClient)
			{
			if(	req->iAddedPolicies.Count() == 0 && req->iOriginalControlPolicies.Count() == 0
				&& req->iRemovedPolicies.Count() == 0)
				{
				// Check if it's OK to add this request to the list.
				// This is done by just storing the message. 
				if( req->iMessage.IsNull() )
					{
					req->iMessage = aMessage;
					return KErrNone;
					}
				// If message is not null, something is wrong.
				return KErrGeneral;
				}
			// If we have a stored message, complete it. Should not happen!
			if( !req->iMessage.IsNull() )
				{
                __ALFFXLOGSTRING("CPolicyEventReq:: Message complete, stored message, should not happen");
				req->iMessage.Complete( KErrNone );
	    		// NULLify the message pointer after it has been completed.
	    		// If not done, we can't check if the message is valid or not.
				req->iMessage = RMessagePtr2();
				return KErrNone;
				}
            // Otherwise complete this message.
            __ALFFXLOGSTRING("CPolicyEventReq:: Message complete, return policy count");
            aMessage.Complete( req->TotalPolicyCount() );
			return KErrNone;
			}
		}
	// Client not found. Insert it!
	err = InsertClient( aMessage );
	if( err != KErrNotFound )	
		{
		// If failed to insert the client, complete the message so it may try again.
		// Also, if there are control policies, we report the number of them
		// If error is KErrNotFound, we have stored the message, and it will be completed
		// later (as soon as there are policies)
        __ALFFXLOGSTRING1("CPolicyEventReq:: insert client returned %d", err);
		aMessage.Complete( err );
		}
	return KErrNone;
	}
LOCAL_C void Test5()
//
// Test OpenFileScan
//
	{

	test.Next(_L("Scan for open files - mixed RDirs and RFiles"));

	RFile file1,file2,file3;
	TFileName fn;
	fn = _L("Z:\\TEST\\T_FSRV.CPP");
	fn[0] = gExeFileName[0];
	TInt r=file1.Open(TheFs,fn,EFileRead|EFileShareReadersOnly);
	test(r==KErrNone);
	fn = _L("Z:\\TEST\\T_FILE.CPP");
	fn[0] = gExeFileName[0];
	r=file2.Open(TheFs,fn,EFileRead);
	test(r==KErrNone);
	fn = _L("Z:\\TEST\\T_FSRV.CPP");
	fn[0] = gExeFileName[0];
	r=file3.Open(TheFs,fn,EFileRead|EFileShareReadersOnly);
	test(r==KErrNone);
	
	RDir dir1,dir2,dir3,dir4;
	fn = _L("Z:\\TEST\\*.XDE");
	fn[0] = gExeFileName[0];
	r=dir1.Open(TheFs,fn,KEntryAttMaskSupported);
	test(r==KErrNone);
	r=dir2.Open(TheFs,fn,KEntryAttMaskSupported);
	test(r==KErrNone);
	r=dir3.Open(TheFs,fn,KEntryAttMaskSupported);
	test(r==KErrNone);
	r=dir4.Open(TheFs,fn,KEntryAttMaskSupported);
	test(r==KErrNone);

	CFileList* list;
	TOpenFileScan fileScan(TheFs);
	fileScan.NextL(list);

	if (gRunByBatch)
		{
		test(list!=NULL);
		test(list->Count()==1);
		TEntry entry=(*list)[0];
		test(entry.iName.FindF(_L(".BAT"))>=0);
		delete list;
		fileScan.NextL(list);
		}

	test(list!=NULL);
	TInt count=list->Count();
	test(count==3);
	TEntry entry=(*list)[0];
	test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
	entry=(*list)[1];
	test(entry.iName.FindF(_L("T_FILE.CPP"))>=0);
	entry=(*list)[2];
	test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
	TThreadId threadId=fileScan.ThreadId();
	RThread current;
	TThreadId currentId=current.Id();
	test(threadId==currentId);
	delete list;

	fileScan.NextL(list);
	test(list==NULL);

	file1.Close();
	file2.Close();
	file3.Close();
	dir1.Close();
	dir2.Close();
	dir3.Close();
	dir4.Close();
	}
LOCAL_C void Test4()
//
// Test openfilescan - rdirs, empty, full, empty rdirs.
//
	{
	test.Next(_L("Scan for open files - check RDir sessions are ignored"));

	RFs fs1,fs2,fs3,fs4;
	TFileName fn;
	TInt r=fs1.Connect();
	test(r==KErrNone);
	r=fs2.Connect();
	test(r==KErrNone);
	r=fs3.Connect();
	test(r==KErrNone);
	r=fs4.Connect();
	test(r==KErrNone);

	RDir dir1,dir2,dir3,dir4;
	fn = _L("Z:\\TEST\\*.XDE");
	fn[0] = gExeFileName[0];
	r=dir1.Open(TheFs,fn,KEntryAttMaskSupported);
	test(r==KErrNone);
	r=dir2.Open(TheFs,fn,KEntryAttMaskSupported);
	test(r==KErrNone);
	r=dir3.Open(TheFs,fn,KEntryAttMaskSupported);
	test(r==KErrNone);
	r=dir4.Open(TheFs,fn,KEntryAttMaskSupported);
	test(r==KErrNone);

	RFile file1,file2,file3;
	fn = _L("Z:\\TEST\\T_FSRV.CPP");
	fn[0] = gExeFileName[0];
	r=file1.Open(fs2,fn,EFileRead|EFileShareReadersOnly);
	test(r==KErrNone);
	fn = _L("Z:\\TEST\\T_FILE.CPP");
	fn[0] = gExeFileName[0];
	r=file2.Open(fs2,fn,EFileRead);
	test(r==KErrNone);
	fn = _L("Z:\\TEST\\T_FSRV.CPP");
	fn[0] = gExeFileName[0];
	r=file3.Open(fs2,fn,EFileRead|EFileShareReadersOnly);
	test(r==KErrNone);
	
	RDir dir5,dir6,dir7,dir8;
	fn = _L("Z:\\TEST\\*.XDE");
	fn[0] = gExeFileName[0];
	r=dir5.Open(fs4,fn,KEntryAttMaskSupported);
	test(r==KErrNone);
	r=dir6.Open(fs4,fn,KEntryAttMaskSupported);
	test(r==KErrNone);
	r=dir7.Open(fs4,fn,KEntryAttMaskSupported);
	test(r==KErrNone);
	r=dir8.Open(fs4,fn,KEntryAttMaskSupported);
	test(r==KErrNone);

	CFileList* list;
	TOpenFileScan fileScan(TheFs);
	fileScan.NextL(list);

	if (gRunByBatch)
		{
		test(list!=NULL);
		test(list->Count()==1);
		TEntry entry=(*list)[0];
		test(entry.iName.FindF(_L(".BAT"))>=0);
		delete list;
		fileScan.NextL(list);
		}

	test(list!=NULL);
	TInt count=list->Count();
	test(count==3);
	TEntry entry=(*list)[0];
	test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
	entry=(*list)[1];
	test(entry.iName.FindF(_L("T_FILE.CPP"))>=0);
	entry=(*list)[2];
	test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
	TThreadId threadId=fileScan.ThreadId();
	RThread current;
	TThreadId currentId=current.Id();
	test(threadId==currentId);
	delete list;

	fileScan.NextL(list);
	test(list==NULL);

	file1.Close();
	file2.Close();
	file3.Close();
	dir1.Close();	dir2.Close();
	dir3.Close();	dir4.Close();
	dir5.Close();	dir6.Close();
	dir7.Close();	dir8.Close();
	fs1.Close();	fs2.Close();
	fs3.Close();	fs4.Close();
	}
LOCAL_C void Test3()
//
// Test openfilescan - empty, full, empty full
//
	{
	test.Next(_L("Scan for open files - multiple sessions"));

	RFs fs1,fs2,fs3,fs4;
	TInt r=fs1.Connect();
	test(r==KErrNone);
	r=fs2.Connect();
	test(r==KErrNone);
	r=fs3.Connect();
	test(r==KErrNone);
	r=fs4.Connect();
	test(r==KErrNone);

	RFile file1,file2,file3;
	TFileName fn;
	fn = _L("Z:\\TEST\\T_FSRV.CPP");
	fn[0] = gExeFileName[0];
	r=file1.Open(fs2,fn,EFileRead|EFileShareReadersOnly);
	test(r==KErrNone);
	fn = _L("Z:\\TEST\\T_FILE.CPP");
	fn[0] = gExeFileName[0];
	r=file2.Open(fs2,fn,EFileRead|EFileShareReadersOnly);
	test(r==KErrNone);
	fn = _L("Z:\\TEST\\T_FSRV.CPP");
	fn[0] = gExeFileName[0];
	r=file3.Open(fs2,fn,EFileRead|EFileShareReadersOnly);
	test(r==KErrNone);
	
	r=file1.Open(fs4,fn,EFileRead|EFileShareReadersOnly);
	test(r==KErrNone);
	fn = _L("Z:\\TEST\\T_FILE.CPP");
	fn[0] = gExeFileName[0];
	r=file2.Open(fs4,fn,EFileRead|EFileShareReadersOnly);
	test(r==KErrNone);
	fn = _L("Z:\\TEST\\T_FSRV.CPP");
	fn[0] = gExeFileName[0];
	r=file3.Open(fs4,fn,EFileRead|EFileShareReadersOnly);
	test(r==KErrNone);
	
	CFileList* list;
	TOpenFileScan fileScan(TheFs);
	fileScan.NextL(list);

	if (gRunByBatch)
		{
		test(list!=NULL);
		test(list->Count()==1);
		TEntry entry=(*list)[0];
		test(entry.iName.FindF(_L(".BAT"))>=0);
		delete list;
		fileScan.NextL(list);
		}

	test(list!=NULL);
	TInt count=list->Count();
	test(count==3);
	TEntry entry=(*list)[0];
	test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
	entry=(*list)[1];
	test(entry.iName.FindF(_L("T_FILE.CPP"))>=0);
	entry=(*list)[2];
	test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
	TThreadId threadId=fileScan.ThreadId();
	RThread current;
	TThreadId currentId=current.Id();
	test(threadId==currentId);
	delete list;

	fileScan.NextL(list);
	test(list!=NULL);
	count=list->Count();
	test(count==3);
	entry=(*list)[0];
	test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
	entry=(*list)[1];
	test(entry.iName.FindF(_L("T_FILE.CPP"))>=0);
	entry=(*list)[2];
	test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
	threadId=fileScan.ThreadId();
	currentId=current.Id();
	test(threadId==currentId);
	delete list;

	fileScan.NextL(list);
	test(list==NULL);

	file1.Close();
	file2.Close();
	file3.Close();
	fs1.Close();
	fs2.Close();
	fs3.Close();
	fs4.Close();
	}
示例#29
0
LOCAL_C void TestCodeSetupDrive(RThread &thread)
{
	/* The CodeModifier driver (look in ../debug/d_codemodifier) takes two threads, we just use the
	** first one */
	test(KErrNone==Device.ThreadId(0, thread.Id()));
}
示例#30
0
void CCmdSpinlock::DoRunL()
{
    if (iPriority)
    {
#ifdef FSHELL_MEMORY_ACCESS_SUPPORT
        LoadMemoryAccessL();

        RThread me;
        CleanupClosePushL(me);
        LeaveIfErr(me.Open(me.Id()), _L("Couldn't open myself (!?!)"));
        LeaveIfErr(iMemAccess.SetThreadPriority(me, iPriority), _L("Couldn't set priority"));
        CleanupStack::PopAndDestroy(&me);
#else
        PrintWarning(_L("--priority is not supported if memoryaccess is not available."));
#endif
    }

    if (iStartIn)
    {
        Printf(_L("Starting in %d seconds...\r\n"), iStartIn);
        User::After(iStartIn * 1000000);
    }

    if (iDuration)
    {
        Printf(_L("Starting to spin for %d seconds... (Press CTRL-C to exit earlier)\r\n"), iDuration);
    }
    else
    {
        Printf(_L("Starting to spin... (Press CTRL-C to exit)\r\n"));
    }

    // We have ~300,000 cycles per millisecond to play with. We will do some amount of work then wait a millisecond.
    // This is pretty arbitrary.

    TInt tickPeriod;
    HAL::Get(HAL::ENanoTickPeriod, tickPeriod);

    TInt endTime; // in nkern ticks
    if (iDuration)
    {
        endTime = User::NTickCount() + (iDuration * 1000000)/tickPeriod;
    }
    else
    {
        endTime = KMaxTInt;
    }

    if (iLoad)
    {
        //TODO this loop needs sorting out. The User::After is a bit broken.
        TInt n = iLoad * 1000;
        while (User::NTickCount() < (TUint)endTime)
        {
            for (iCounter = 0; iCounter < n; iCounter++)
            {
                // Let's do an exec call just for fun
                UserSvr::DebugMask(0);
            }

            User::After(1000); // Wait 1 ms
        }
    }
    else
    {
        // Just spin
        while (User::NTickCount() < (TUint)endTime)
        {
        }
    }
}