mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
optimization: test address before fetching messages for it
This commit is contained in:
parent
9951064439
commit
5f9b2e431f
1 changed files with 17 additions and 15 deletions
|
@ -859,24 +859,26 @@ CookieRef::send_stored_messages( HostID dest, const AddrInfo* addr )
|
|||
logf( XW_LOGVERBOSE0, "%s(dest=%d)", __func__, dest );
|
||||
assert( dest > 0 && dest <= 4 );
|
||||
|
||||
DBMgr* dbmgr = DBMgr::Get();
|
||||
const char* cname = ConnName();
|
||||
vector<DBMgr::MsgInfo> msgs;
|
||||
dbmgr->GetStoredMessages( cname, dest, msgs );
|
||||
if ( addr->isCurrent() ) {
|
||||
DBMgr* dbmgr = DBMgr::Get();
|
||||
const char* cname = ConnName();
|
||||
vector<DBMgr::MsgInfo> msgs;
|
||||
dbmgr->GetStoredMessages( cname, dest, msgs );
|
||||
|
||||
vector<int> sentIDs;
|
||||
vector<DBMgr::MsgInfo>::const_iterator iter;
|
||||
for ( iter = msgs.begin(); addr->isCurrent() && msgs.end() != iter;
|
||||
++iter ) {
|
||||
DBMgr::MsgInfo msg = *iter;
|
||||
if ( ! send_with_length( addr, dest,
|
||||
(const unsigned char*)msg.msg.c_str(),
|
||||
msg.msg.length(), true ) ) {
|
||||
break;
|
||||
vector<int> sentIDs;
|
||||
vector<DBMgr::MsgInfo>::const_iterator iter;
|
||||
for ( iter = msgs.begin(); addr->isCurrent() && msgs.end() != iter;
|
||||
++iter ) {
|
||||
DBMgr::MsgInfo msg = *iter;
|
||||
if ( ! send_with_length( addr, dest,
|
||||
(const unsigned char*)msg.msg.c_str(),
|
||||
msg.msg.length(), true ) ) {
|
||||
break;
|
||||
}
|
||||
sentIDs.push_back( msg.msgID );
|
||||
}
|
||||
sentIDs.push_back( msg.msgID );
|
||||
dbmgr->RemoveStoredMessages( sentIDs );
|
||||
}
|
||||
dbmgr->RemoveStoredMessages( sentIDs );
|
||||
} /* send_stored_messages */
|
||||
|
||||
bool
|
||||
|
|
Loading…
Reference in a new issue