Exemplo n.º 1
0
//---------------------------------------------------------------------------
//	@function:
//		FSimulateIOErrorInternal
//
//	@doc:
//		Inject I/O exception
//
//---------------------------------------------------------------------------
static BOOL
FSimulateIOErrorInternal
	(
	INT iErrno,
	const CHAR *szFile,
	ULONG ulLine
	)
{
	BOOL fRes = false;

	ITask *ptsk = ITask::PtskSelf();
	if (NULL != ptsk &&
	    ptsk->FTrace(EtraceSimulateIOError) &&
	    CFSimulator::Pfsim()->FNewStack(CException::ExmaSystem, CException::ExmiIOError) &&
	    !GPOS_MATCH_EX(ptsk->Perrctxt()->Exc(), CException::ExmaSystem, CException::ExmiIOError))
	{
		// disable simulation temporarily to log injection
		CAutoTraceFlag(EtraceSimulateIOError, false);

		CLogger *plogger = dynamic_cast<CLogger*>(ITask::PtskSelf()->Ptskctxt()->PlogErr());
		if (!plogger->FLogging())
		{
			GPOS_TRACE_FORMAT_ERR("Simulating I/O error at %s:%d", szFile, ulLine);
		}

		errno = iErrno;

		if (ptsk->Perrctxt()->FPending())
		{
			ptsk->Perrctxt()->Reset();
		}

		// inject I/O error
		fRes = true;
	}

	return fRes;
}
Exemplo n.º 2
0
//---------------------------------------------------------------------------
//	@function:
//		netutils::FSimulateNetError
//
//	@doc:
//		Inject networking exception
//
//---------------------------------------------------------------------------
BOOL
gpos::netutils::FSimulateNetError
	(
	INT iErrno,
	const CHAR *szFile,
	ULONG ulLine
	)
{
	GPOS_ASSERT(0 < iErrno);

	ITask *ptsk = ITask::PtskSelf();
	if (NULL != ptsk &&
	    ptsk->FTrace(EtraceSimulateNetError) &&
	    CFSimulator::Pfsim()->FNewStack(CException::ExmaSystem, CException::ExmiNetError) &&
	    !GPOS_MATCH_EX(ptsk->Perrctxt()->Exc(), CException::ExmaSystem, CException::ExmiNetError))
	{
		// disable simulation temporarily to log injection
		CAutoTraceFlag(EtraceSimulateNetError, false);

		CLogger *plogger = dynamic_cast<CLogger*>(ITask::PtskSelf()->Ptskctxt()->PlogErr());
		if (!plogger->FLogging())
		{
			GPOS_TRACE_FORMAT_ERR("Simulating networking error at %s:%d", szFile, ulLine);
		}

		errno = iErrno;

		if (ptsk->Perrctxt()->FPending())
		{
			ptsk->Perrctxt()->Reset();
		}

		return true;
	}

	return false;
}