/**
This function is called by the Child Thread
1.	Create a session with the server
2.	Test an SendReceive call
3.	Informs the main thread about the status of the call using
	a.	iSessionCreated, if the a connection is established
	b.	iResultServer, holds the return value for connection 
	c.	iResultSr, the return value of SendReceive	call
*/
TInt CEASShdOpCodeGetAlarmIdListByState1Step::Exec_SendReceiveL()
	{
	iResultServer = CreateSession(iSrServerName,Version(),KAlarmServerAsynchronousSlotCount);

	if (iResultServer!=KErrNone)
		{
		iResultServer=StartServer();
		if (iResultServer!=KErrNone)
			{
			return(iResultServer);
			}
		iResultServer = CreateSession(iSrServerName,Version(),KAlarmServerAsynchronousSlotCount);
		}
	if(iResultServer == 0)
		{
		iSessionCreated = ETrue;
		if(iSrMessageId >= 0)
			{
			TPckgBuf<TInt> state;
			TPckgBuf<TInt> size;
			iResultSr =	SendReceive(iSrMessageId,TIpcArgs(&state, &size));
			}
		}
	return iResultServer;
	}
/**
	This Fn is called by the Child Thread
1.	Create a session with the server
2.	Test an SendReceive call
3.	Informs the main thread about the status of the call using
	a.	iSessionCreated, if the a connection is established
	b.	iResult_Server, holds the return value for connection 
	c.	iResult_SR, the return value of SendReceive	call
*/
TInt CRSDbgMarkHeap1Step::Exec_SendReceive()
	{
	iResult_Server = CreateSession(SR_ServerName,Version(),2);

	if (iResult_Server!=KErrNone)
		{
		iResult_Server=StartServer();
		if (iResult_Server!=KErrNone)
			{
			return(iResult_Server);
			}

		iResult_Server = CreateSession(SR_ServerName,TVersion(),2);
		}
		
	if(iResult_Server == 0)
		{
		iSessionCreated = ETrue;
		if(SR_MESSAGE_ID >= 0)
			{
			iResult_SR	=	SendReceive(SR_MESSAGE_ID,TIpcArgs(0,0,0,0));
			}
		}

	return iResult_Server;
	}
Beispiel #3
0
/**
 Connect to the CLE server with the specified name. If the server is not found, this function will attempt to start it
 and retry connecting to it.
 
@param aServerName The name of the CLE server to connect to
@leave KErrNoMemory if no memory.
@leave One of the system-wide error codes.
*/
void RCleSession::ConnectL(const TDesC& aServerName)
	{
	// Guard against multiple calls.
	if( KNullHandle != iHandle )
		{
		User::Leave( KErrAlreadyExists );
		}

	TInt err = CreateSession(aServerName, iVersion, KCleSrvMsgSlots);
	if( (KErrNotFound == err) || (KErrServerTerminated == err) )
		{
		err = CCleServer::StartCleSrv(aServerName);

		DEBUGPRINT2(_L("Starting CleSrv completed with %d"),err);
		if (KErrNone !=  err && KErrAlreadyExists != err)
			{
			User::Leave(err);
			}

		User::LeaveIfError( CreateSession(aServerName, iVersion, KCleSrvMsgSlots) );
		}
	else
		{
		User::LeaveIfError( err );
		}	
	}	
/*
Exec_SendReceive():
	This Fn is called by the Child Thread
1.	Create a session with the server
2.	Test an SendReceive call
3.	Informs the main thread about the status of the call using
	a.	iSessionCreated, if the a connection is established
	b.	iResult_Server, holds the return value for connection 
	c.	iResult_SR, the return value of SendReceive	call
*/
TInt CECompactionStatus1Step::Exec_SendReceive()
	{
	iResult_Server = CreateSession(SR_ServerName,Version(),2);

	if (iResult_Server!=KErrNone)
		{

		iResult_Server=StartServer();
		if (iResult_Server!=KErrNone)
			return(iResult_Server);

		iResult_Server = CreateSession(SR_ServerName, Version(),2);
		}
	if(iResult_Server == KErrNone)
		{
		iSessionCreated = ETrue;
		if(SR_MESSAGE_ID >= 0)
			{
			if(SR_MESSAGE_TYPE == KSyncMessage)
				{
				iResult_SR	=	SendReceive(SR_MESSAGE_ID,TIpcArgs(0,0,0,0));
				}
			else
				{
				TRequestStatus status;
				SendReceive(SR_MESSAGE_ID,TIpcArgs(0,0,0,0), status);
				iResult_SR = WaitForSomeTimeAndDecide(status);
				}
			}
		}

	return iResult_Server;
	}
Beispiel #5
0
/*
Exec_SendReceive():
	This Fn is called by the Child Thread
1.	Create a session with the server
2.	Test an SendReceive call
3.	Informs the main thread about the status of the call using
	a.	iSessionCreated, if the a connection is established
	b.	iResult_Server, holds the return value for connection 
	c.	iResult_SR, the return value of SendReceive	call
*/
TInt CECntCreateDatabase1Step::Exec_SendReceive()
	{
	iResult_Server = CreateSession(SR_ServerName,Version(),2);

	if (iResult_Server!=KErrNone)
		{

		iResult_Server=StartServer();
		if (iResult_Server!=KErrNone)
			return(iResult_Server);

		iResult_Server = CreateSession(SR_ServerName,TVersion(),2);
		}
	if(iResult_Server == 0)
		{
		iSessionCreated = ETrue;
		if(SR_MESSAGE_ID >= 0)
			{
			HBufC *buf = NULL;
			TRAPD(err, buf = HBufC::NewL(1000) );
			TEST(err == KErrNone);
			TPtr ptr = buf->Des();
			iResult_SR	=	SendReceive(SR_MESSAGE_ID,TIpcArgs(&ptr,&ptr,&ptr,&ptr));
			delete buf;
			}
		}

	return iResult_Server;
	}
EXPORT_C void RPackagerTestClient::ConnectL()
/** Check and create server process if it is not already running,
then create a server session. Also constructs packager member. */
	{
	// Assume the server is already running and attempt to create a session
	// 4 message slots
	TInt err = CreateSession(KPackagerServerTestName,TVersion(1,1,1),4);
	if(err == KErrNotFound)
		{
		// Server not running
		// Use the RProcess API to start it.
		RProcess server;
		User::LeaveIfError(server.Create(KPackagerServerTestExe,KNullDesC));

		// Synchronise with the server
		TRequestStatus reqStatus;
		server.Rendezvous(reqStatus);
		// Start the test harness
		server.Resume();
		// Server will call the reciprocal static synchronise cal User::WaitForRequest(reqStatus);
		User::WaitForRequest(reqStatus);
		server.Close();
		User::LeaveIfError(reqStatus.Int() != KErrNone);
		// Create the root server session
		User::LeaveIfError(CreateSession(KPackagerServerTestName,TVersion(0,0,0),4));
		}		
		
	iPackager = CCntPackager::NewL();
	}
//------------------------------------------------------------
// RCntParserServer::Connect()
//------------------------------------------------------------
EXPORT_C TInt RCntParserServer::Connect()
	{
	LOGGER_ENTERFN( "RCntParserServer::Connect()" );

	TInt r = KErrNone;

	if( iConnected == ECntParserNotConnected )
		{
		r = CreateSession( KCntParserName, Version(), KDefaultMessageSlots );
		if(r==KErrNone) 
			{
			iConnected=ECntParserConnected;	
			}
		else
			{
			RProcess p;
			TInt err = p.Create(KTxtServer, KNullDesC);
	   		if ( err != KErrNone )
           		{
           		// Loading failed.
           		return err;
           		}
			TRequestStatus status;
			p.Rendezvous( status );
			if( status != KRequestPending )
				{
				p.Kill(0);		// abort startup
				p.Close();
				return KErrGeneral;   // status can be KErrNone: don't return status.Int()
				}
			else
				{
				p.Resume();	// logon OK - start the server
				}
			
			User::WaitForRequest( status );

			if( status != KErrNone )
				{
				p.Close();
				return status.Int();
				}

			r = CreateSession( KCntParserName, Version() );
			if( r == KErrNone )
				{
				iConnected = ECntParserConnected;	
				}
			p.Close();
			}
		}
	else
		{
		r = KErrCouldNotConnect;
		}
	LOGGER_WRITE_1( "RCntParserServer::Connect() : return %d", r );
	return r; 
	}
void UCreateSessionCallbackProxyAdvanced::Activate()
{
	FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("CreateSession"), GEngine->GetWorldFromContextObject(WorldContextObject));
	
	if (PlayerControllerWeakPtr.IsValid() )
		Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());

	if (Helper.OnlineSub != nullptr)
	{
		auto Sessions = Helper.OnlineSub->GetSessionInterface();
		if (Sessions.IsValid())
		{
			CreateCompleteDelegateHandle = Sessions->AddOnCreateSessionCompleteDelegate_Handle(CreateCompleteDelegate);
			
			FOnlineSessionSettings Settings;
			Settings.NumPublicConnections = NumPublicConnections;
			Settings.bShouldAdvertise = true;
			Settings.bAllowJoinInProgress = true;
			Settings.bIsLANMatch = bUseLAN;
			Settings.bUsesPresence = bUsePresence;
			Settings.bAllowJoinViaPresence = true;
			Settings.bIsDedicated = bDedicatedServer;
			Settings.bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
			Settings.bAntiCheatProtected = bAntiCheatProtected;
			Settings.bUsesStats = bUsesStats;
			Settings.bShouldAdvertise = bShouldAdvertise;

			// These are about the only changes over the standard Create Sessions Node
			Settings.bAllowInvites = bAllowInvites;
			
			FOnlineSessionSetting ExtraSetting;
			for (int i = 0; i < ExtraSettings.Num(); i++)
			{
				ExtraSetting.Data = ExtraSettings[i].Data;
				//		ViaOnlineServiceAndPing
				ExtraSetting.AdvertisementType = EOnlineDataAdvertisementType::ViaOnlineService;
				Settings.Settings.Add(ExtraSettings[i].Key, ExtraSetting);
			}
			

			if (PlayerControllerWeakPtr.IsValid() && Helper.UserID.IsValid())
				Sessions->CreateSession(*Helper.UserID, GameSessionName, Settings);
			else
				Sessions->CreateSession(0, GameSessionName, Settings);

			// OnCreateCompleted will get called, nothing more to do now
			return;
		}
		else
		{
			FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning);
		}
	}

	// Fail immediately
	OnFailure.Broadcast();
}
TInt RSecMgrSession::Connect()
    {
    RTSecMgrTraceFunction("RSecMgrSession::Connect()") ;
    TInt err(KErrNone);
        // Try to create a Server session
    err = CreateSession ( KSecServerProcessName, Version (),
            KDefaultMessageSlots);

    if ( err != KErrNotFound && err != KErrServerTerminated)
        {
        // KErrNone or unrecoverable error
        if ( err != KErrNone)
            {
#ifdef _DEBUG
            RDebug::Print(KServerStartFailed);
#endif
            }
        
        }
    else
        {
        // Return code was KErrNotFound or KErrServerTerminated.
        // Try to start a new security manager server instance
        TInt retry(KSecSrvClientTryCount);
        while(retry > 0)
            {
            err = StartSecManagerServer ();
            if ( err != KErrNone && err != KErrAlreadyExists)
                {
                // Unrecoverable error
                #ifdef _DEBUG
                            RDebug::Print(KServerStartFailed);
                #endif
                retry = 0;
                }
            else
                {
                err = CreateSession ( KSecServerProcessName, Version (),
                                                KDefaultMessageSlots);
                if(err != KErrNotFound && err != KErrServerTerminated)
                    {
                    if ( err != KErrNone)
                                {
                    #ifdef _DEBUG
                                RDebug::Print(KServerStartFailed);
                    #endif
                                }
                    retry = 0;
                    }
                }
            retry--;
            }
        }       
    return (err);
    }
// ---------------------------------------------------------------------------
// Connect to the notifier server. Start the server if necessary.
// ---------------------------------------------------------------------------
//
EXPORT_C TInt RBTNotifier::Connect()
    {
    TInt err = CreateSession( KBTNotifServerName, Version() );
    if( err == KErrNotFound || err == KErrServerTerminated )
        {
        err = StartBTNotifSrv();
        if( err == KErrNone || err == KErrAlreadyExists )
            {
            err = CreateSession( KBTNotifServerName, Version() );
            }
        }
    return err;
    }
Beispiel #11
0
TInt CPARAM_MESS_NAMEStep::Exec_SendReceive()
	{
	_LIT(KEsockSessStartMutex,"KESSMTX"); //Keep the descriptor short
	RMutex mutex;
	TInt r;
	// Protect the openning of the session
	// with a mutex to stop thread collision
	FOREVER
		{
		r = mutex.CreateGlobal(KEsockSessStartMutex());
		if (r == KErrNone)
			break;
		if (r != KErrAlreadyExists)
			return r;
		r=mutex.OpenGlobal(KEsockSessStartMutex());
		if (r == KErrNone)
			break;
		if (r != KErrNotFound)
			return r;
		}
	mutex.Wait(); // the exclusion ensures the session is started atomically
	iResult_Server=CreateSession(SOCKET_SERVER_NAME,Version());
	// Because ESock is now loaded by the Comms Root Server which is generally started during
	// the boot this should commonly succeed; however for test code this is still a possibility
	// Hence here we try starting it; this is an atomic operation (and cheap if it's already started)
	if (iResult_Server==KErrNotFound)
		{
		r=StartC32();
		if (r==KErrNone || r==KErrAlreadyExists)
			{
			iResult_Server=CreateSession(SOCKET_SERVER_NAME,Version());
			}
		}
	mutex.Signal();
	mutex.Close();

	if (iResult_Server == KErrNone)
		{
		iSessionCreated = ETrue;

		const TInt test_id = dispatch_num<PARAM_MESS_VALUE>::result;

		iResult_SR = do_execute(Int2Type<test_id>());
		}
	else
		{
		iSessionCreated = EFalse;
		return 0;
		}
	return r;
	}
EXPORT_C TInt RUpsTestServ::Connect(const TDesC& aServerName, TBool aDebugMode)
/**
 * @param aServerName - Human readable name of the test server
 * @param aDebugMode - Set to true for just in time debugging
 * @return int - Standard error codes
 * Secure version of the API call. Expects the server binary to be
 * ServerXXX.exe
 */
	{
	if(aServerName.Length() > iServerName.MaxLength())
		return KErrTooBig;
	iServerName = aServerName;
	// Assume the server is already running and attempt to create a session
	// 4 message slots
	TInt err = CreateSession(aServerName,Version(),-1);
	if(err == KErrNotFound || err == KErrServerTerminated)
		{
		// Server not running
		// Construct the server binary name
		TBuf<KMaxTestExecuteNameLength> serverFile;
		RProcess server;
		_LIT(KEmpty,"");
		_LIT(KExe,".exe");

		serverFile.Copy(aServerName);
		serverFile.Append(KExe);
		err = server.Create(serverFile,KEmpty);
		if(err != KErrNone)
			return err;
		// Synchronise with the server
		TRequestStatus reqStatus;
		server.Rendezvous(reqStatus);

		// Set just in time debugging for the process
		if(aDebugMode)
			server.SetJustInTime(ETrue);
		else
			server.SetJustInTime(EFalse);

		// Start the test harness
		server.Resume();
		// Server will call the reciprocal static synchronise call
		User::WaitForRequest(reqStatus);
		server.Close();
		if(reqStatus.Int() != KErrNone)
			return reqStatus.Int();
		// Create the root server session
		err = CreateSession(aServerName,Version(),-1);
		}
	return err;
	}
Beispiel #13
0
// ---------------------------------------------------------
// RLbtServer::Connect
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
EXPORT_C TInt RLbtServer::Connect()
	{
 	__ASSERT_ALWAYS(Handle() == 0, User::Panic(KLbtClientPanicCategory, ELbtServerHandleNotClosed));
	
	TRAPD(ret, ConstructL());

	if (ret == KErrNone)
		{
		ret = CreateSession(KLbtServerCoreName, Version(), KDefaultMessageSlots);
		
		if( ret == KErrNotFound )
		    {
		    RProcess lbtServer;
		    ret = lbtServer.Create(KServerCoreProcessName, KNullDesC);
		    
		    if( ret != KErrNone )
		        {
		        lbtServer.Close();
		        return ret;
		        }
		    
		    TRequestStatus status;
		    lbtServer.Rendezvous(status);
		    
		    if( status != KRequestPending )
		        {
		        User::WaitForRequest(status);
		        lbtServer.Kill(KErrNone);
		        lbtServer.Close();
		        return KErrNotFound;
		        }
		    else
		        {
		        lbtServer.Resume();		        
		        }

		    User::WaitForRequest(status);
		    lbtServer.Close();
		    ret = status.Int();

		    if( !( ret == KErrNone || ret == KErrAlreadyExists ) )
		        {
		        return ret;
		        }

		    ret = CreateSession(KLbtServerCoreName, Version(), KDefaultMessageSlots);		    
		    }
        }
	return ret;
    }
EXPORT_C TInt RMMFAudioPolicyProxy::Open(RServer2& aPolicyServerHandle)
	{
	TServerStart start(aPolicyServerHandle);
	TInt err = KErrNone;
	if(aPolicyServerHandle.Handle())
		{
		// Server is already running and attempt to create a session
		// 4 message slots
		err = CreateSession(aPolicyServerHandle, TVersion(KMMFAudioPolicyVersion,
														KMMFAudioPolicyMinorVersionNumber,
														KMMFAudioPolicyBuildVersionNumber));
		if(err != KErrNone)
			{
			return err;	
			}
		}
	else
		{
		TThreadFunction serverFunc = CMMFAudioPolicyServer::StartThread;
		RThread server;
		err = server.Create(_L(""),serverFunc, KAudioPolicyServerStackSize,
						KAudioPolicyServerInitHeapSize, KAudioPolicyServerMaxHeapSize,
						&start, EOwnerProcess);
		if(err != KErrNone)
			return err;
			// Synchronise with the server
		TRequestStatus reqStatus;
		server.Rendezvous(reqStatus);
		if (reqStatus!=KRequestPending)
			{
			server.Kill(0);
			}
		else 
			{
			// Start the test harness
			server.Resume();
			// Server will call the reciprocal static synchronise call
			}
		User::WaitForRequest(reqStatus); // wait for start or death
		server.Close();
		if(reqStatus.Int() != KErrNone)
			{
			return reqStatus.Int();
			}
		err = CreateSession(aPolicyServerHandle, TVersion(KMMFAudioPolicyVersion,
								 KMMFAudioPolicyMinorVersionNumber,
								 KMMFAudioPolicyBuildVersionNumber));
		}
	return err;		
	}
Beispiel #15
0
EXPORT_C TInt RTestExecuteLogServ::Connect()
/**
 * @return int - Standard error codes
 * EKA2 all variants and EKA1 target.
 * Server is an exe
 */
	{
	TVersion version(KTestExecuteLoggerMajorVersion,KTestExecuteLoggerMinorVersion,KTestExecuteLoggerBuildVersion);
	// Assume the server is already running and attempt to create a session
	TInt err = CreateSession(KTestExecuteLogServerName,version,8);
	if(err == KErrNotFound)
		{
		// Server not running
		// Construct the server binary name
		_LIT(KEmpty,"");
		// EKA2 is simple
		// No path required
		TBuf<32> serverFile;
		serverFile.Copy(KTestExecuteLogServerName);
		_LIT(KExe,".exe");
		serverFile.Append(KExe);
		RProcess server;
		err = server.Create(serverFile,KEmpty);
		if(err != KErrNone)
			return err;
		// Synchronise with the server
		TRequestStatus reqStatus;
		server.Rendezvous(reqStatus);
		server.Resume();
		// Server will call the reciprocal static synchronise call
		User::WaitForRequest(reqStatus);
		server.Close();
		if(reqStatus.Int() != KErrNone)
			return reqStatus.Int();
		// Create the root server session
		err = CreateSession(KTestExecuteLogServerName,version,8);
		}

#ifdef TEF_SHARE_AUTO
	// Makes the session shared among all threads in the process
  	if( err == KErrNone )
  		{
  		err = ShareAuto();
  		}
#endif

	return err;
	}
// ============================================================================
// RCwrtRegistryClientSession::Connect()
// Connect to widgetregistry server
//
// ============================================================================
//
EXPORT_C TInt RWACRegistryClientSession::Connect()
    {
    TInt startupAttempts = KWACRegistryServerStartupAttempts;

    for ( ;; )
        {
        TInt ret = CreateSession( KWACRegistryName, Version(),
            KWACRegistryServerAsynchronousSlotCount );

        if ( ret != KErrNotFound && ret != KErrServerTerminated )
            {
            return ret;
            }

        if ( startupAttempts-- == 0 )
            {
            return ret;
            }

        ret = StartServer();
        if ( ret != KErrNone && ret != KErrAlreadyExists )
            {
            return ret;
            }
        }
    }
Beispiel #17
0
bool MSDKVpp::SetVppParam(VADisplay* pVaDpy, VppConfig* pVppCfg, Measurement* pMeasuremnt, bool bUseMeasure)
{
    if (!pVppCfg)
    {
        VPP_TRACE_ERROR("Invalid input vpp parameters, set parameters failed\n");
        return false;
    }
    m_vppCfg = *pVppCfg;
    if (VPP_COMP == m_mode && bUseMeasure)
        m_pMeasuremnt = pMeasuremnt;

    if (!m_pVpp)
    {
#ifdef CONFIG_USE_MFXALLOCATOR
        if (!CreateSessionAllocator(pVaDpy))
            return false;
#else
        MFXVideoSession* pSession = CreateSession(*pVaDpy);
        if (!pSession)
        {
            VPP_TRACE_ERROR("[MSDKVpp]-----Create session failed\n");
            return false;
        }
        m_pSession = pSession;
#endif
        m_pVpp = new MFXVideoVPP(*m_pSession);
    }
    return true;
}
Beispiel #18
0
    //  Open a URL for playback.
    void Player_::open_url( ev::OpenURL const& openurl)
    {
      // 1. Create a new media session.
      // 2. Create the media source.
      // 3. Create the topology.
      // 4. Queue the topology [asynchronous]
      // 5. Start playback [asynchronous - does not happen in this method.]

      IMFTopologyPtr pTopology;
      IMFPresentationDescriptorPtr pSourcePD;

      // Create the media session.
      CreateSession();

      // Create the media source.
      m_pSource = CreateMediaSource(openurl.url());

      // Create the presentation descriptor for the media source.
      THROW_IF_ERR(m_pSource->CreatePresentationDescriptor(&pSourcePD));

      // Create a partial topology.
      pTopology = CreatePlaybackTopology(m_pSource, pSourcePD, m_hwndVideo);

      // Set the topology on the media session.
      THROW_IF_ERR(m_pSession->SetTopology(0, pTopology.Get()));

//      OnOpenURL_();

      // m_state = OpenPending;

      // If SetTopology succeeds, the media session will queue an 
      // MESessionTopologySet event.
    }
// Connect to the  server - default number of message slots = 4
TInt RMessageServ::Connect()
{
    TInt r=KErrNone;//StartThread();
    if (r==KErrNone)
        r=CreateSession(KMessageServerName3,Version(),kDefaultMessageSlots);
    return(r);
}
void UCreateSessionCallbackProxy::Activate()
{
	FOnlineSubsystemBPCallHelper Helper(TEXT("CreateSession"), GEngine->GetWorldFromContextObject(WorldContextObject));
	Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());

	if (Helper.IsValid())
	{
		auto Sessions = Helper.OnlineSub->GetSessionInterface();
		if (Sessions.IsValid())
		{
			CreateCompleteDelegateHandle = Sessions->AddOnCreateSessionCompleteDelegate_Handle(CreateCompleteDelegate);

			FOnlineSessionSettings Settings;
			Settings.NumPublicConnections = NumPublicConnections;
			Settings.bShouldAdvertise = true;
			Settings.bAllowJoinInProgress = true;
			Settings.bIsLANMatch = bUseLAN;
			Settings.bUsesPresence = true;
			Settings.bAllowJoinViaPresence = true;

			Sessions->CreateSession(*Helper.UserID, GameSessionName, Settings);

			// OnCreateCompleted will get called, nothing more to do now
			return;
		}
		else
		{
			FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning);
		}
	}

	// Fail immediately
	OnFailure.Broadcast();
}
/*
----------------------------------------------------------------------------------------
// This is the standard retry pattern for server connection
----------------------------------------------------------------------------------------
*/
TInt RExampleServerClient::Connect()
{
	TInt retry=2;
	for (;;)
	{
		TInt r=CreateSession(KCrashServerName,
		TVersion(SServMajorVersionNumber,
                 SServMinorVersionNumber,
                 SServBuildVersionNumber)
		,1);
		if (r!=KErrNotFound && r!=KErrServerTerminated)
		{
			return r;
		}
		if (--retry==0)
		{
			return r;
		}
		r=StartServer();
		
		if (r!=KErrNone && r!=KErrAlreadyExists)
		{
			return r;
		}
	}
}
// ---------------------------------------------------------------------------
// Connect()
//
// Connect to CertProvisionInfoServer
// ---------------------------------------------------------------------------
//
TInt RInfoServerClient::Connect()
{
    BTIC_TRACE_PRINT("[CInfoServerClient] Connect --->");

    TInt retry( 2 );

    for (;;)
    {
        TInt status =
            CreateSession( KBTICCertProvInfoServer, TVersion( 0, 0, 0 ), 1 );

        if ( ( status != KErrNotFound ) && ( status != KErrServerTerminated ) )
        {
            return status;
        }

        if ( --retry == 0 )
        {
            return status;
        }

        status = StartServer();

        if ( ( status != KErrNone ) && ( status != KErrAlreadyExists ) )
        {
            return status;
        }
    }
}
TInt RSignalSession::Connect()
	{
	TInt retry = 2; // A maximum of two iterations of the loop required
	for(;;)
		{
			TInt r = CreateSession(KServerName,TVersion(KIpcServerMajorVersionNumber,
										KIpcServerMinorVersionNumber,
										KIpcServerBuildVersionNumber), -1,
										EIpcSession_Sharable);

			if ( (KErrNotFound != r) && (KErrServerTerminated != r) )
				{
				return r;
				}
			if ( --retry == 0 )
				{
				return r;
				}
			r = StartServer();
			if ( (KErrNone != r) && (KErrAlreadyExists != r) )
				{
				return r;
				}
		}
	}
Beispiel #24
0
EXPORT_C TInt RVpnServ::Connect()
/**
 * Opens a connection (session) to the VPN Manager server.
 *
 * @return KErrNone if the connection succeeds, a system-wide error code
 * if not.
 */
    {
    const TInt KVpnManagerServerStackSize    = 0x4000;
    const TInt KVpnManagerServerInitHeapSize = 0x1000;
    const TInt KVpnManagerServerMaxHeapSize  = 0x1000000;

    TInt retry = 2;

	  for (;;)
        {
        TInt r=CreateSession(KVpnManagerServer,
                             Version(),
                             KDefaultMessageSlots);

        if (r!=KErrNotFound && r!=KErrServerTerminated)
            return r;
        if (--retry==0)
            return r;
        r = Launcher::LaunchServer(KVpnManagerServer, KVpnManagerFile,
                                   KVpnManagerUid3, KVpnManagerServerInitHeapSize,
                                   KVpnManagerServerMaxHeapSize, KVpnManagerServerStackSize);

        if (r!=KErrNone && r!=KErrAlreadyExists)
            return r;
        }
    }
Beispiel #25
0
bool LLBC_IocpPoller::HandleConnecting(int waitRet, LLBC_POverlapped ol, int errNo, int subErrNo)
{
    if (ol->opcode != LLBC_OverlappedOpcode::Connect)
        return false;

    _Connecting::iterator it = _connecting.find(ol->sock);
    LLBC_AsyncConnInfo &asyncInfo = it->second;

    LLBC_Socket *sock = asyncInfo.socket;
    sock->DeleteOverlapped(ol);

    if (waitRet == LLBC_OK)
    {
        sock->SetOption(SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0);
        SetConnectedSocketDftOpts(sock);

        _svc->Push(LLBC_SvcEvUtil::BuildAsyncConnResultEv(
            true, LLBC_StrError(LLBC_ERROR_SUCCESS), asyncInfo.peerAddr));

        AddSession(CreateSession(sock, asyncInfo.sessionId), false);
    }
    else
    {
        _svc->Push(LLBC_SvcEvUtil::BuildAsyncConnResultEv(
                false, LLBC_StrErrorEx(errNo, subErrNo), asyncInfo.peerAddr));
        LLBC_Delete(asyncInfo.socket);
    }

    _connecting.erase(it);
    return true;
}
/**
Connects to the  server using 4 message slots.

In this example, the server is implemented as a separate thread.
The function starts that thread before attempting to create a session with the server.

The version information specifies the earliest version of the server that we can
talk to.
*/
TInt RCountSession::Connect()
	{
	TInt r=StartThread(iServerThread);
	if (r==KErrNone)
		r=CreateSession(KCountServerName,Version(),kDefaultMessageSlots);
	return(r); 
	}
// -----------------------------------------------------------------------------
// RPhCltServer::Connect
// 
// Creates connection to the server. If server is not running,
// it is also launched.
// -----------------------------------------------------------------------------
//
EXPORT_C TInt RPhCltServer::Connect( TInt aMessageSlots )
    {
    TInt err = KErrGeneral;
    TInt count = KPhCltNumberOfRetryAttempts;
    FOREVER
        {
        err = CreateSession( PHONE_SERVER_NAME, Version(), aMessageSlots );
        if ( err != KErrNotFound && err != KErrServerTerminated )
            {
            break;
            }
        // Need to restart server
        if ( --count < 0 )
            {
            break;
            }
        err = StartServer();
        if ( err != KErrNone && err != KErrAlreadyExists )
            {
            if ( err != KErrNotFound )
                {
                break;
                }
            Panic( EPhCltPanicServerUnexpectedServerNotFound );
            }
        }
    return err;
    }
EXPORT_C TInt RFTokenClient::Connect()
    {
    TInt err = KErrNone;
    TFindServer serveFinder(FTOKEN_SERVER_NAME);
    TFullName fullName;
    if (serveFinder.Next(fullName) != KErrNone)
        {
 	    const TUidType serverUid(KNullUid,KNullUid,KServerUid3);

	    RProcess server;
	    err = server.Create(_L("Z:\\sys\\bin\\!ftokenserver.exe"),FTOKEN_SERVER_NAME,serverUid);
	    if (!err)
	        {
        	TRequestStatus stat;
	        server.Rendezvous(stat);
	        if (stat!=KRequestPending)
	            {
		        server.Kill(0);         // abort startup
	            }
	        else
	            {
		        server.Resume();        // logon OK - start the server
	            }
	        User::WaitForRequest(stat);             // wait for start or death
	        err = stat.Int();
	        }
        }

    if ( !err )
        {
        err = CreateSession(FTOKEN_SERVER_NAME,TVersion(1,1,1)); 
        }

	return err;
    }
EXPORT_C TInt RClassControllerClient::Connect()
	{
	TInt retry = 2;

	FOREVER
		{
		//Create Session, With server name from shared header 
		//And lowest version number of the server with which this client is compatible. 
		//Number of message slots available, -1 for meessages from global free pool

		TInt err = CreateSession(KServerName, TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber), KMessageSlots);

		if ((err != KErrNotFound) && (err != KErrServerTerminated))
			{
			return err;
			}

		if (--retry == 0)
			{
			return err;
			}

		err = StartServer();

		if ((err != KErrNone) && (err != KErrAlreadyExists))
			{
			return err;
			}
		}
	}
// ---------------------------------------------------------------------------
// RSecuiDialogNotifierSrv::Connect()
// ---------------------------------------------------------------------------
//
TInt RSecuiDialogNotifierSrv::Connect()
    {
    TRACE( "RSecuiDialogNotifierSrv::Connect" );
    const TInt KMaxCreateSessionAttepmts = 2;
    TInt retry = KMaxCreateSessionAttepmts;
    FOREVER
        {
        TInt err = CreateSession( KSecuiDialogNotifierServerName, Version() );
        TRACE( "RSecuiDialogNotifierSrv::Connect, create session err=%d", err );
        if( err != KErrNotFound && err != KErrServerTerminated )
            {
            return err;
            }

        if( --retry == 0 )
            {
            return err;
            }

        err = StartServer();
        if( err != KErrNone && err != KErrAlreadyExists )
            {
            return err;
            }
        }
    }