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 );
|
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
|
||||||
|
|
Loading…
Reference in a new issue