Example #1
0
int clsConnWorker::AddAllListen()
{
	int iRet;

	uint32_t iLocalAcceptorID = m_poConf->GetLocalAcceptorID();
	vector<Endpoint_t> vecAcceptorEndpoint = m_poConf->GetAcceptorEndpoints();
	AssertLess(iLocalAcceptorID, vecAcceptorEndpoint.size());

	Endpoint_t tInternal = vecAcceptorEndpoint[iLocalAcceptorID];
	Endpoint_t tExteranl = m_poConf->GetExtpoint();

	iRet = AddListen(true, tInternal);
	if (iRet != 0)
	{
		CertainLogError("AddListen ret %d", iRet);
		return -1;
	}

	iRet = AddListen(false, tExteranl);
	if (iRet != 0)
	{
		CertainLogError("AddListen ret %d", iRet);
		return -2;
	}

	return 0;
}
Example #2
0
string clsEntityWorker::MakePaxosValue(clsClientCmd *poCmd,
		bool bUseNoopForReadOnly)
{
	int iRet;

	RawPacket_t *lp = (RawPacket_t *)m_pcBuffer;

	if (bUseNoopForReadOnly && poCmd->IsReadOnly())
	{
		clsNoopCmd oNoopCmd(poCmd->GetEntityID(), poCmd->GetEntry());
		oNoopCmd.SetUUID(poCmd->GetUUID());
		iRet = oNoopCmd.SerializeToArray(m_pcBuffer + RP_HEADER_SIZE,
				m_iBufferSize);
		lp->iCmdID = oNoopCmd.GetCmdID();
	}
	else
	{
		iRet = poCmd->SerializeToArray(m_pcBuffer + RP_HEADER_SIZE,
				m_iBufferSize);
		lp->iCmdID = poCmd->GetCmdID();
	}

	AssertLess(0, iRet);

	lp->iStartFlag = VALUE_STATR_FLAG;
	lp->iReverse = 0;
	lp->iCheckSum = 0;
	lp->iLen = iRet;

	return string(m_pcBuffer, RP_HEADER_SIZE + iRet);
}
Example #3
0
// iPtr is for check only.
int clsAsyncPipeMng::SyncWriteByPipeIdx(uint32_t iIdx, uintptr_t iPtr)
{
    CertainLogDebug("iIdx %u iPtr %lu", iIdx, iPtr);
    AssertLess(iIdx, MAX_ASYNC_PIPE_NUM);

    int iOutFD = m_aaAsyncPipe[iIdx][1];
    int iRet = write(iOutFD, &iPtr, sizeof(iPtr));
    AssertEqual(iRet, sizeof(iPtr));
    return 0;
}
Example #4
0
int clsConnInfoMng::PutByOneThread(uint32_t iAcceptorID,
		const ConnInfo_t &tConnInfo)
{
	AssertNotEqual(iAcceptorID, m_iLocalAcceptorID);

	CertainLogDebug("iAcceptorID %u local %s:%hu peer %s:%hu",
			iAcceptorID, tConnInfo.tLocalAddr.sIP, tConnInfo.tLocalAddr.hPort,
			tConnInfo.tPeerAddr.sIP, tConnInfo.tPeerAddr.hPort);

	clsThreadLock oLock(&m_oMutex);

	if (iAcceptorID == INVALID_ACCEPTOR_ID)
	{
		m_tExtConnQueue.push(tConnInfo);
	}
	else
	{
		AssertLess(iAcceptorID, m_iAcceptorNum);
		m_vecIntConnQueue[iAcceptorID].push(tConnInfo);
	}

	return 0;
}