mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
sometimes a device goes away and we don't notice, so when it comes
back just reuse its record rather than asserting there's no record there.
This commit is contained in:
parent
45998fd2c0
commit
23a59e8097
2 changed files with 23 additions and 12 deletions
|
@ -972,11 +972,15 @@ CookieRef::increasePlayerCounts( CRefEvent* evt, bool reconn, HostID* hidp,
|
|||
|
||||
{
|
||||
RWWriteLock rwl( &m_socketsRWLock );
|
||||
HostRec* hr = new HostRec( hostid, addr, nPlayersH, seed, !reconn );
|
||||
HostRec* hr = m_sockets[hostid-1];
|
||||
if ( NULL == hr ) {
|
||||
hr = new HostRec( hostid, addr, nPlayersH, seed, !reconn );
|
||||
m_sockets[hostid-1] = hr;
|
||||
} else {
|
||||
hr->update( addr, nPlayersH, seed, !reconn );
|
||||
}
|
||||
logf( XW_LOGINFO, "%s: adding socket rec with ts %lx", __func__,
|
||||
addr->created() );
|
||||
assert( NULL == m_sockets[hostid-1] );
|
||||
m_sockets[hostid-1] = hr;
|
||||
}
|
||||
|
||||
printSeeds(__func__);
|
||||
|
|
|
@ -46,14 +46,21 @@ struct HostRec {
|
|||
public:
|
||||
HostRec(HostID hostID, const AddrInfo* addr, int nPlayersH, int seed,
|
||||
bool ackPending )
|
||||
: m_addr(*addr)
|
||||
, m_nPlayersH(nPlayersH)
|
||||
, m_seed(seed)
|
||||
, m_lastHeartbeat(uptime())
|
||||
, m_ackPending(ackPending)
|
||||
: m_seed(seed)
|
||||
{
|
||||
update( addr, nPlayersH, seed, ackPending );
|
||||
logf( XW_LOGINFO, "%s created HostRec with id %d", __func__, hostID);
|
||||
}
|
||||
void update( const AddrInfo* addr, int nPlayersH, int seed, bool ackPending )
|
||||
{
|
||||
assert( seed == m_seed );
|
||||
m_addr = *addr;
|
||||
m_nPlayersH = nPlayersH;
|
||||
m_seed = seed;
|
||||
m_lastHeartbeat = uptime();
|
||||
m_ackPending = ackPending;
|
||||
}
|
||||
|
||||
AddrInfo m_addr;
|
||||
int m_nPlayersH;
|
||||
int m_seed;
|
||||
|
|
Loading…
Reference in a new issue