mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
need to clear CID of record in DB when killing corresponding in-memory
cref or reconnect will fail.
This commit is contained in:
parent
452e3fc86b
commit
2b702b48d6
3 changed files with 16 additions and 2 deletions
|
@ -482,6 +482,7 @@ CRefMgr::Recycle_locked( CookieRef* cref )
|
|||
{
|
||||
logf( XW_LOGINFO, "%s(cref=%p,cookie=%s)", __func__, cref, cref->Cookie() );
|
||||
CookieID id = cref->GetCookieID();
|
||||
DBMgr::Get()->ClearCID( cref->ConnName() );
|
||||
cref->Clear();
|
||||
addToFreeList( cref );
|
||||
|
||||
|
@ -501,7 +502,7 @@ CRefMgr::Recycle_locked( CookieRef* cref )
|
|||
}
|
||||
++iter;
|
||||
}
|
||||
|
||||
assert( iter != m_cookieMap.end() ); /* we found something */
|
||||
|
||||
#ifdef RELAY_HEARTBEAT
|
||||
if ( m_cookieMap.size() == 0 ) {
|
||||
|
|
|
@ -52,7 +52,7 @@ DBMgr::DBMgr()
|
|||
|
||||
/* Now figure out what the largest cid currently is. There must be a way
|
||||
to get postgres to do this for me.... */
|
||||
/* const char* query = "SELECT cid FROM games ORDER BY - cid LIMIT 1"; */
|
||||
/* const char* query = "SELECT cid FROM games ORDER BY cid DESC LIMIT 1"; */
|
||||
/* PGresult* result = PQexec( m_pgconn, query ); */
|
||||
/* if ( 0 == PQntuples( result ) ) { */
|
||||
/* m_nextCID = 1; */
|
||||
|
@ -191,6 +191,18 @@ DBMgr::AddCID( const char* const connName, CookieID cid )
|
|||
execSql( query );
|
||||
}
|
||||
|
||||
void
|
||||
DBMgr::ClearCID( const char* connName )
|
||||
{
|
||||
const char* fmt = "UPDATE " TABLE_NAME " SET cid = null "
|
||||
"WHERE connName = '%s'";
|
||||
char query[256];
|
||||
snprintf( query, sizeof(query), fmt, connName );
|
||||
logf( XW_LOGINFO, "%s: query: %s", __func__, query );
|
||||
|
||||
execSql( query );
|
||||
}
|
||||
|
||||
void
|
||||
DBMgr::ClearCIDs( void )
|
||||
{
|
||||
|
|
|
@ -43,6 +43,7 @@ class DBMgr {
|
|||
|
||||
void AddPlayers( const char* const connName, int nToAdd );
|
||||
void AddCID( const char* connName, CookieID cid );
|
||||
void ClearCID( const char* connName );
|
||||
|
||||
private:
|
||||
DBMgr();
|
||||
|
|
Loading…
Reference in a new issue