Beispiel #1
0
bool CUserInfoSession::OnStartSession (const SArchonMessage &Msg, DWORD dwTicket)

//	OnStartSession
//
//	Start

	{
	//	Send an Aeon message to get the user record

	CComplexArray *pPayload = new CComplexArray;
	pPayload->Insert(USERS_TABLE_NAME);
	pPayload->Insert(m_sUsernameKey);

	//	Send message

	ISessionHandler::SendMessageCommand(ADDRESS_AEON_COMMAND,
			MSG_AEON_GET_VALUE,
			GenerateAddress(PORT_CRYPTOSAUR_COMMAND),
			CDatum(pPayload),
			MESSAGE_TIMEOUT);

	//	Expect reply

	return true;
	}
Beispiel #2
0
bool CRunSession::HandleResult (CHexeProcess::ERunCodes iRun, CDatum dResult)

//	HandleResult
//
//	Handles the result from a run

	{
	switch (iRun)
		{
		case CHexeProcess::runOK:
		case CHexeProcess::runError:
			SendMessageReply(MSG_REPLY_DATA, dResult);
			//	FALSE means we're done with the session
			return false;

		case CHexeProcess::runAsyncRequest:
			{
			SendMessageCommand(dResult.GetElement(0), 
					dResult.GetElement(1), 
					GenerateAddress(PORT_HEXE_COMMAND),
					dResult.GetElement(2),
					MESSAGE_TIMEOUT);

			m_iState = stateWaitingForHexarcReply;

			return true;
			}

		default:
			//	LATER:
			SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, CString("LATER"));
			return false;
		}
	}
Beispiel #3
0
bool CUserInfoSession::UpdateLoginFailure (void)

//	UpdateLoginFailure
//
//	Update the user record with the most recent failure

	{
	//	Set our state

	m_iState = stateWaitingForFailureUpdate;

	//	Mutate the record to set the login date

	CComplexStruct *pRecord = new CComplexStruct;
	pRecord->SetElement(FIELD_LOGIN_FAILURE_COUNT, CDatum((int)1));

	CComplexStruct *pMutation = new CComplexStruct;
	pMutation->SetElement(FIELD_LAST_LOGIN_FAILURE_ON, MUTATE_DATE_MODIFIED);
	pMutation->SetElement(FIELD_LOGIN_FAILURE_COUNT, MUTATE_INCREMENT);

	//	Create a payload

	CComplexArray *pPayload = new CComplexArray;
	pPayload->Insert(USERS_TABLE_NAME);
	pPayload->Insert(m_sUsernameKey);
	pPayload->Insert(CDatum(pRecord));
	pPayload->Insert(CDatum(pMutation));

	//	Send message

	ISessionHandler::SendMessageCommand(ADDRESS_AEON_COMMAND,
			MSG_AEON_MUTATE,
			GenerateAddress(PORT_CRYPTOSAUR_COMMAND),
			CDatum(pPayload),
			MESSAGE_TIMEOUT);

	//	Expect reply

	return true;
	}
Beispiel #4
0
bool CArchonProcess::Boot (const SProcessDesc &Config)

//	Boot
//
//	Boots the process. We take ownership of all engines.

	{
	try
		{
		int i;

		//	Get our current process location

		CString sExecutableFilespec = fileGetExecutableFilespec();
		CString sExecutablePath = fileGetPath(sExecutableFilespec);

		//	LATER: Hard-coded for now

		m_sArcology = STR_DEFAULT_ARCOLOGY;

		//	Set some options

		m_bArcologyPrime = ((Config.dwFlags & PROCESS_FLAG_ARCOLOGY_PRIME) != 0);
		m_bCentralModule = ((Config.dwFlags & PROCESS_FLAG_CENTRAL_MODULE) != 0);
		m_bConsoleMode = ((Config.dwFlags & PROCESS_FLAG_CONSOLE_MODE) != 0);
		m_bDebugger = ((Config.dwFlags & PROCESS_FLAG_DEBUG) != 0);

		m_sMachineName = Config.sMachineName;

		//	Set the name

		if (m_bCentralModule)
			m_sName = STR_CENTRAL_MODULE;
		else
			{
			//	Get a module name by taking just the filename (without extension)

			fileGetExtension(fileGetFilename(sExecutableFilespec), &m_sName);
			}

		m_iState = stateNone;

		//	Initialize the black box so that we can record boot errors.
		//	(But only if we're the central module on arcology prime).

		if (m_bCentralModule
				&& m_bArcologyPrime)
			{
			m_BlackBox.Boot(sExecutablePath);
			if (Config.dwFlags & PROCESS_FLAG_CONSOLE_OUTPUT)
				m_BlackBox.SetConsoleOutput(true);

			LogBlackBox(STR_ARCHON_BOOT);
			}
		else if (m_bConsoleMode)
			{
			m_BlackBox.SetConsoleOutput(true);
			}

		//	Validate options

		if (m_sMachineName.IsEmpty() && !m_bConsoleMode)
			{
			LogBlackBox(ERR_NO_MACHINE_NAME);
			m_iState = stateBootError;
			return false;
			}

		//	Get version information

		if (!fileGetVersionInfo(NULL_STR, &m_Version))
			{
			LogBlackBox(ERR_UNABLE_TO_GET_VERSION);
			m_iState = stateBootError;
			return false;
			}

		//	Log version information

		if (m_bCentralModule || m_bConsoleMode)
			{
			LogBlackBox(strPattern("%s %s", m_Version.sProductName, m_Version.sProductVersion));
			LogBlackBox(m_Version.sCopyright);
			}

		//	Boot Foundation, including Winsock

		CString sError;
		if (!CFoundation::Boot(0, &sError))
			{
			LogBlackBox(sError);
			m_iState = stateBootError;
			return false;
			}

		//	Init some stuff

		m_dwLastGarbageCollect = sysGetTickCount();
		m_QuitEvent.Create();
		m_RunEvent.Create();
		m_PauseEvent.Create();
		m_QuitSignalEvent.Create();

		//	If we're the Central Module, then claim a mutex so that no one
		//	else tries it.

		if (m_bCentralModule)
			{
			if (m_bArcologyPrime)
				m_CentralModuleSem.Create(STR_ARCOLOGY_PRIME_SEMAPHORE, 1);
			else
				m_CentralModuleSem.Create(STR_CENTRAL_MODULE_SEMAPHORE, 1);

			if (!m_CentralModuleSem.TryIncrement())
				{
				LogBlackBox(ERR_NOT_CENTRAL_MODULE);
				m_iState = stateBootError;
				return false;
				}
			}

		//	Boot some stuff

		m_MnemosynthDb.Boot(this);
		m_Transporter.Boot(this);

		//	Boot some threads

		m_ImportThread.Boot(this, m_sName, m_RunEvent, m_PauseEvent, m_QuitEvent);

		//	Remember the Exarch engine, if we have it.

		m_pExarch = Config.pExarch;

		//	Add the list of engines

		DWORD dwEngineID = 0;

		//	Add the mnemosynth engine (if not in console mode)

		if (!m_bConsoleMode)
			{
			SEngine *pEngine = m_Engines.Insert();
			pEngine->pEngine = new CMnemosynthEngine(&m_MnemosynthDb);
			pEngine->pEngine->Boot(this, dwEngineID++);
			}

		//	Add user provided engines

		for (i = 0; i < Config.Engines.GetCount(); i++)
			{
			SEngine *pEngine = m_Engines.Insert();
			pEngine->pEngine = Config.Engines[i].pEngine;

			//	Allow the engine to add its ports

			pEngine->pEngine->Boot(this, dwEngineID++);
			}

		//	After this point we cannot create or destroy any engines.
		//
		//	Get all engine's command port (in case we need it).
		//	It is OK if an engine does not have a command port; that just means
		//	that it doesn't want any messages from us.

		for (i = 0; i < m_Engines.GetCount(); i++)
			m_Engines[i].pCommand = Bind(GenerateAddress(strPattern("%s.command", m_Engines[i].pEngine->GetName())));

		//	Publish this module's virtual ports to Mnemosynth

		m_Transporter.PublishToMnemosynth();

		//	Done

		return true;
		}
	catch (...)
		{
		LogBlackBox(ERR_CRASH_WHILE_BOOTING);
		m_iState = stateBootError;
		return false;
		}
	}
Beispiel #5
0
void CArchonProcess::Log (const CString &sMsg, const CString &sText)

//	Log
//
//	Log a status or error from the engine

	{
	CString sAddress;

	//	In console mode we just output

	if (m_bConsoleMode)
		{
		LogBlackBox(strPattern("%s: %s", sMsg, sText));
		return;
		}

	//	We don't want to recurse, so we keep track here.

	static __declspec(thread) bool bInLog = false;
	if (bInLog)
		{
#ifdef DEBUG
		printf("ERROR: Unable to log: %s\n", (LPSTR)sText);
#endif
		return;
		}

	bInLog = true;

	//	Protect ourselves in case we crash

	try
		{
		//	If we are Arcology Prime, then we send to our machine's Exarch

		if (m_bArcologyPrime)
			sAddress = ADDRESS_EXARCH_LOG;

		//	Otherwise we need to send to Arcology Prime

		else
			{
			//	NOTE: We can't easily cache this because Arcology Prime might change
			//	(if it restarts, for example).

			sAddress = m_Transporter.GenerateMachineAddress(STR_ARCOLOGY_PRIME, ADDRESS_EXARCH_LOG);
			if (sAddress.IsEmpty())
				{
				bInLog = false;
				return;
				}
			}

		//	Compose the message

		SArchonMessage Msg;
		Msg.sMsg = sMsg;
		Msg.sReplyAddr = ADDR_NULL;
		Msg.dwTicket = 0;

		//	Log the message and the machine/module that it came from

		CComplexArray *pArray = new CComplexArray;
		pArray->Insert(sText);
		pArray->Insert(GenerateAddress(PORT_ARC_LOG));
		Msg.dPayload = CDatum(pArray);

		//	NOTE: We need to use a real address (instead of a virtual port) because the log
		//	command is used before virtual ports replicate to all modules.

		SendMessage(sAddress, Msg);
		}
	catch (...)
		{
#ifdef DEBUG
		printf("ERROR: Crash in log.\n");
#endif
		}

	bInLog = false;
	}
Beispiel #6
0
		CResizeImageSession (CHyperionEngine &Engine, const CString &sFilePath, DWORD dwNewSize, const CString &sCacheID, const CHexeSecurityCtx *pSecurityCtx) : 
				CAeonFileDownloadSession(GenerateAddress(PORT_HYPERION_COMMAND), sFilePath, pSecurityCtx),
				m_Engine(Engine),
				m_dwNewSize(dwNewSize),
				m_sCacheID(sCacheID)
			{ }