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 );
|
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__,
|
logf( XW_LOGINFO, "%s: adding socket rec with ts %lx", __func__,
|
||||||
addr->created() );
|
addr->created() );
|
||||||
assert( NULL == m_sockets[hostid-1] );
|
|
||||||
m_sockets[hostid-1] = hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printSeeds(__func__);
|
printSeeds(__func__);
|
||||||
|
|
|
@ -44,16 +44,23 @@ class CookieMapIterator; /* forward */
|
||||||
|
|
||||||
struct HostRec {
|
struct HostRec {
|
||||||
public:
|
public:
|
||||||
HostRec(HostID hostID, const AddrInfo* addr, int nPlayersH, int seed,
|
HostRec(HostID hostID, const AddrInfo* addr, int nPlayersH, int seed,
|
||||||
bool ackPending )
|
bool ackPending )
|
||||||
: m_addr(*addr)
|
: m_seed(seed)
|
||||||
, m_nPlayersH(nPlayersH)
|
{
|
||||||
, m_seed(seed)
|
update( addr, nPlayersH, seed, ackPending );
|
||||||
, m_lastHeartbeat(uptime())
|
logf( XW_LOGINFO, "%s created HostRec with id %d", __func__, hostID);
|
||||||
, m_ackPending(ackPending)
|
}
|
||||||
{
|
void update( const AddrInfo* addr, int nPlayersH, int seed, bool ackPending )
|
||||||
logf( XW_LOGINFO, "%s created HostRec with id %d", __func__, hostID);
|
{
|
||||||
|
assert( seed == m_seed );
|
||||||
|
m_addr = *addr;
|
||||||
|
m_nPlayersH = nPlayersH;
|
||||||
|
m_seed = seed;
|
||||||
|
m_lastHeartbeat = uptime();
|
||||||
|
m_ackPending = ackPending;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddrInfo m_addr;
|
AddrInfo m_addr;
|
||||||
int m_nPlayersH;
|
int m_nPlayersH;
|
||||||
int m_seed;
|
int m_seed;
|
||||||
|
|
Loading…
Reference in a new issue