|
reSIProcate/stack
9694
|
#include <TuSelector.hxx>

Definition at line 19 of file TuSelector.hxx.
typedef std::vector<Item> resip::TuSelector::TuList [private] |
Definition at line 63 of file TuSelector.hxx.
| TuSelector::TuSelector | ( | TimeLimitFifo< Message > & | fallBackFifo | ) |
Definition at line 16 of file TuSelector.cxx.
References mShutdownFifo, and resip::FifoStatsInterface::setDescription().
: mFallBackFifo(fallBackFifo), mCongestionManager(0), mFallbackPostNotify(0), mTuSelectorMode(false), mStatsPayload() { mShutdownFifo.setDescription("TuSelector::mShutdownFifo"); }

| TuSelector::~TuSelector | ( | ) |
Definition at line 26 of file TuSelector.cxx.
{
//assert(mTuList.empty());
}
| void TuSelector::add | ( | Message * | msg, |
| TimeLimitFifo< Message >::DepthUsage | usage | ||
| ) |
Definition at line 64 of file TuSelector.cxx.
References resip::TimeLimitFifo< Msg >::add(), DebugLog, exists(), resip::Message::getTransactionUser(), resip::AsyncProcessHandler::handleProcessNotification(), resip::Message::hasTransactionUser(), InfoLog, resip::StatisticsMessage::loadOut(), resip::StatisticsMessage::logStats(), mFallBackFifo, mFallbackPostNotify, mStatsPayload, resip::TransactionUser::postToTransactionUser(), RESIPROCATE_SUBSYSTEM, and WarningLog.
Referenced by resip::SipStack::post(), resip::StatelessHandler::process(), resip::TransactionController::process(), resip::TransactionState::process(), resip::TuSelectorTimerQueue::processTimer(), resip::TransactionController::send(), and resip::TransactionState::sendToTU().
{
if (msg->hasTransactionUser())
{
if (exists(msg->getTransactionUser()))
{
DebugLog (<< "Send to TU: " << *(msg->getTransactionUser()) << " " << std::endl << std::endl << *msg);
msg->getTransactionUser()->postToTransactionUser(msg, usage);
}
else
{
WarningLog (<< "Send to TU that no longer exists: " << std::endl << std::endl << *msg);
delete msg;
}
}
else
{
StatisticsMessage* stats = dynamic_cast<StatisticsMessage*>(msg);
if (stats)
{
InfoLog(<< "Stats message " );
stats->loadOut(mStatsPayload);
stats->logStats(RESIPROCATE_SUBSYSTEM, mStatsPayload);
delete msg;
}
else
{
DebugLog(<< "Send to default TU: " << std::endl << std::endl << *msg);
mFallBackFifo.add(msg, usage);
if ( mFallbackPostNotify )
mFallbackPostNotify->handleProcessNotification();
}
}
}

| void TuSelector::add | ( | ConnectionTerminated * | term | ) |
Definition at line 100 of file TuSelector.cxx.
References resip::ConnectionTerminated::clone(), InfoLog, and mTuList.
{
InfoLog (<< "Sending " << *term << " to TUs");
for(TuList::const_iterator it = mTuList.begin(); it != mTuList.end(); it++)
{
if (!it->shuttingDown && it->tu->isRegisteredForConnectionTermination())
{
it->tu->post(term->clone());
}
}
}

| void TuSelector::add | ( | KeepAlivePong * | pong | ) |
Definition at line 114 of file TuSelector.cxx.
References resip::KeepAlivePong::clone(), and mTuList.
{
//InfoLog (<< "Sending " << *pong << " to TUs");
for(TuList::const_iterator it = mTuList.begin(); it != mTuList.end(); it++)
{
if (!it->shuttingDown && it->tu->isRegisteredForKeepAlivePongs())
{
it->tu->post(pong->clone());
}
}
}

| bool TuSelector::exists | ( | TransactionUser * | tu | ) | [private] |
| UInt32 TuSelector::getExpectedWait | ( | TransactionUser * | tu | ) | const |
Definition at line 303 of file TuSelector.cxx.
References resip::AbstractFifo< T >::expectedWaitTimeMilliSec(), resip::TransactionUser::getExpectedWait(), and mFallBackFifo.
Referenced by resip::TransactionState::sendToTU().
{
if(tu)
{
return tu->getExpectedWait();
}
return (UInt32)mFallBackFifo.expectedWaitTimeMilliSec();
}

| CongestionManager::RejectionBehavior TuSelector::getRejectionBehavior | ( | TransactionUser * | tu | ) | const |
Definition at line 287 of file TuSelector.cxx.
References resip::CongestionManager::getRejectionBehavior(), resip::TransactionUser::getRejectionBehavior(), mCongestionManager, mFallBackFifo, and resip::CongestionManager::NORMAL.
Referenced by resip::TransactionState::sendToTU().
{
if(!mCongestionManager)
{
return CongestionManager::NORMAL;
}
if(tu)
{
return tu->getRejectionBehavior();
}
return mCongestionManager->getRejectionBehavior(&mFallBackFifo);
}

| unsigned int TuSelector::getTimeTillNextProcessMS | ( | ) |
Definition at line 243 of file TuSelector.cxx.
References resip::AbstractFifo< T >::messageAvailable(), and mShutdownFifo.
Referenced by resip::SipStack::getTimeTillNextProcessMS().
{
if(mShutdownFifo.messageAvailable()) // || !mFallBackFifo.messageAvailable()) // .slg. fallback fifo is not really used
{
return 0;
}
else
{
return INT_MAX;
}
}

| bool resip::TuSelector::haveTransactionUsers | ( | ) | const [inline] |
Definition at line 33 of file TuSelector.hxx.
References mTuSelectorMode.
Referenced by resip::TransactionState::processSipMessageAsNew().
{ return mTuSelectorMode; }
| bool TuSelector::isTransactionUserStillRegistered | ( | const TransactionUser * | tu | ) | const |
Definition at line 256 of file TuSelector.cxx.
References mTuList, and mTuSelectorMode.
Referenced by resip::TransactionState::terminateClientTransaction(), and resip::TransactionState::terminateServerTransaction().
{
if (mTuSelectorMode)
{
for(TuList::const_iterator it = mTuList.begin(); it != mTuList.end(); it++)
{
if (!it->shuttingDown && it->tu == tu)
{
return true;
}
}
}
return false;
}
| void TuSelector::markShuttingDown | ( | TransactionUser * | tu | ) | [private] |
| void TuSelector::process | ( | ) |
Definition at line 39 of file TuSelector.cxx.
References resip::Fifo< Msg >::getNext(), resip::Message::getTransactionUser(), InfoLog, markShuttingDown(), resip::AbstractFifo< T >::messageAvailable(), mShutdownFifo, resip::TransactionUserMessage::RemoveTransactionUser, resip::TransactionUserMessage::RequestShutdown, and resip::TransactionUserMessage::type().
Referenced by resip::SipStack::processTimers().
{
if (mShutdownFifo.messageAvailable())
{
TransactionUserMessage* msg = mShutdownFifo.getNext();
switch (msg->type())
{
case TransactionUserMessage::RequestShutdown:
InfoLog (<< "TransactionUserMessage::RequestShutdown " << *(msg->getTransactionUser()));
markShuttingDown(msg->getTransactionUser());
break;
case TransactionUserMessage::RemoveTransactionUser:
InfoLog (<< "TransactionUserMessage::RemoveTransactionUser " << *(msg->getTransactionUser()));
remove(msg->getTransactionUser());
break;
default:
assert(0);
break;
}
delete msg;
}
}

| void TuSelector::registerTransactionUser | ( | TransactionUser & | tu | ) |
Definition at line 166 of file TuSelector.cxx.
References mTuList, and mTuSelectorMode.
Referenced by resip::SipStack::registerTransactionUser().
{
mTuSelectorMode = true;
mTuList.push_back(Item(&tu));
}
| void TuSelector::remove | ( | TransactionUser * | tu | ) | [private] |
Definition at line 214 of file TuSelector.cxx.
References mTuList, resip::TransactionUser::post(), and resip::TransactionUserMessage::TransactionUserRemoved.
{
for(TuList::iterator it = mTuList.begin(); it != mTuList.end(); it++)
{
if (it->tu == tu)
{
TransactionUserMessage* done = new TransactionUserMessage(TransactionUserMessage::TransactionUserRemoved, tu);
tu->post(done);
mTuList.erase(it);
return;
}
}
assert(0);
}

| void TuSelector::requestTransactionUserShutdown | ( | TransactionUser & | tu | ) |
Definition at line 173 of file TuSelector.cxx.
References resip::Fifo< Msg >::add(), mShutdownFifo, and resip::TransactionUserMessage::RequestShutdown.
Referenced by resip::SipStack::requestTransactionUserShutdown().
{
TransactionUserMessage* msg = new TransactionUserMessage(TransactionUserMessage::RequestShutdown, &tu);
mShutdownFifo.add(msg);
}

| TransactionUser * TuSelector::selectTransactionUser | ( | const SipMessage & | msg | ) |
Definition at line 187 of file TuSelector.cxx.
References mTuList.
Referenced by resip::TransactionState::processSipMessageAsNew().
| void TuSelector::setCongestionManager | ( | CongestionManager * | manager | ) |
Definition at line 272 of file TuSelector.cxx.
References mTuList.
Referenced by resip::SipStack::setCongestionManager().
{
for(TuList::iterator i=mTuList.begin(); i!=mTuList.end();++i)
{
i->tu->setCongestionManager(manager);
}
// Note: We are intentionally not registering the following Fifos
// mFallbackFifo - this is the same fifo as SipStack::TuFifo (passed in
// constructor).
// mShutdownFifo - since it is only used at shutdown time, it doesn need
// congestion management
}
| void TuSelector::setFallbackPostNotify | ( | AsyncProcessHandler * | handler | ) |
Definition at line 33 of file TuSelector.cxx.
References mFallbackPostNotify.
Referenced by resip::SipStack::setFallbackPostNotify().
{
mFallbackPostNotify = handler;
}
| unsigned int TuSelector::size | ( | ) | const |
Definition at line 148 of file TuSelector.cxx.
References mFallBackFifo, mTuList, mTuSelectorMode, and resip::AbstractFifo< T >::size().
Referenced by resip::TransactionController::getTuFifoSize().
{
if (mTuSelectorMode)
{
unsigned int total=0;
for(TuList::const_iterator it = mTuList.begin(); it != mTuList.end(); it++)
{
total += it->tu->size();
}
return total;
}
else
{
return mFallBackFifo.size();
}
}

| void TuSelector::unregisterTransactionUser | ( | TransactionUser & | tu | ) |
Definition at line 180 of file TuSelector.cxx.
References resip::Fifo< Msg >::add(), mShutdownFifo, and resip::TransactionUserMessage::RemoveTransactionUser.
Referenced by resip::SipStack::unregisterTransactionUser().
{
TransactionUserMessage* msg = new TransactionUserMessage(TransactionUserMessage::RemoveTransactionUser, &tu);
mShutdownFifo.add(msg);
}

| bool TuSelector::wouldAccept | ( | TimeLimitFifo< Message >::DepthUsage | usage | ) | const |
Definition at line 128 of file TuSelector.cxx.
References mFallBackFifo, mTuList, mTuSelectorMode, and resip::TimeLimitFifo< Msg >::wouldAccept().
Referenced by resip::TransactionController::isTUOverloaded().
{
if (mTuSelectorMode)
{
for(TuList::const_iterator it = mTuList.begin(); it != mTuList.end(); it++)
{
if (!it->shuttingDown && !it->tu->wouldAccept(usage))
{
return false;
}
}
return true;
}
else
{
return mFallBackFifo.wouldAccept(usage);
}
}

Definition at line 66 of file TuSelector.hxx.
Referenced by getRejectionBehavior().
TimeLimitFifo<Message>& resip::TuSelector::mFallBackFifo [private] |
Definition at line 65 of file TuSelector.hxx.
Referenced by add(), getExpectedWait(), getRejectionBehavior(), size(), and wouldAccept().
Definition at line 67 of file TuSelector.hxx.
Referenced by add(), and setFallbackPostNotify().
Definition at line 68 of file TuSelector.hxx.
Referenced by getTimeTillNextProcessMS(), process(), requestTransactionUserShutdown(), TuSelector(), and unregisterTransactionUser().
Definition at line 70 of file TuSelector.hxx.
Referenced by add().
TuList resip::TuSelector::mTuList [private] |
Definition at line 64 of file TuSelector.hxx.
Referenced by add(), exists(), isTransactionUserStillRegistered(), markShuttingDown(), registerTransactionUser(), remove(), selectTransactionUser(), setCongestionManager(), size(), and wouldAccept().
bool resip::TuSelector::mTuSelectorMode [private] |
Definition at line 69 of file TuSelector.hxx.
Referenced by haveTransactionUsers(), isTransactionUserStillRegistered(), registerTransactionUser(), size(), and wouldAccept().
1.7.5.1