optimization: test address before fetching messages for it

This commit is contained in:
Eric House 2013-07-28 07:28:32 -07:00
parent 9951064439
commit 5f9b2e431f

View file

@ -859,24 +859,26 @@ CookieRef::send_stored_messages( HostID dest, const AddrInfo* addr )
logf( XW_LOGVERBOSE0, "%s(dest=%d)", __func__, dest ); logf( XW_LOGVERBOSE0, "%s(dest=%d)", __func__, dest );
assert( dest > 0 && dest <= 4 ); assert( dest > 0 && dest <= 4 );
DBMgr* dbmgr = DBMgr::Get(); if ( addr->isCurrent() ) {
const char* cname = ConnName(); DBMgr* dbmgr = DBMgr::Get();
vector<DBMgr::MsgInfo> msgs; const char* cname = ConnName();
dbmgr->GetStoredMessages( cname, dest, msgs ); vector<DBMgr::MsgInfo> msgs;
dbmgr->GetStoredMessages( cname, dest, msgs );
vector<int> sentIDs; vector<int> sentIDs;
vector<DBMgr::MsgInfo>::const_iterator iter; vector<DBMgr::MsgInfo>::const_iterator iter;
for ( iter = msgs.begin(); addr->isCurrent() && msgs.end() != iter; for ( iter = msgs.begin(); addr->isCurrent() && msgs.end() != iter;
++iter ) { ++iter ) {
DBMgr::MsgInfo msg = *iter; DBMgr::MsgInfo msg = *iter;
if ( ! send_with_length( addr, dest, if ( ! send_with_length( addr, dest,
(const unsigned char*)msg.msg.c_str(), (const unsigned char*)msg.msg.c_str(),
msg.msg.length(), true ) ) { msg.msg.length(), true ) ) {
break; break;
}
sentIDs.push_back( msg.msgID );
} }
sentIDs.push_back( msg.msgID ); dbmgr->RemoveStoredMessages( sentIDs );
} }
dbmgr->RemoveStoredMessages( sentIDs );
} /* send_stored_messages */ } /* send_stored_messages */
bool bool