diff --git a/xwords4/relay/crefmgr.cpp b/xwords4/relay/crefmgr.cpp index e84a883a8..b052dedb1 100644 --- a/xwords4/relay/crefmgr.cpp +++ b/xwords4/relay/crefmgr.cpp @@ -64,12 +64,15 @@ CRefMgr::CRefMgr() pthread_mutex_init( &m_roomsFilledMutex, NULL ); pthread_mutex_init( &m_freeList_mutex, NULL ); pthread_rwlock_init( &m_cookieMapRWLock, NULL ); + m_db = new DBMgr(); } CRefMgr::~CRefMgr() { assert( this == s_instance ); + delete m_db; + pthread_mutex_destroy( &m_freeList_mutex ); pthread_rwlock_destroy( &m_cookieMapRWLock ); @@ -339,7 +342,9 @@ CRefMgr::getMakeCookieRef_locked( const char* cookie, const char* connName, cref = FindOpenGameFor( cookie, connName, hid, socket, nPlayersH, nPlayersT, gameSeed, langCode, &alreadyHere ); if ( cref == NULL && !alreadyHere ) { - cref = AddNew( cookie, connName, nextCID( NULL ), langCode ); + CookieID cid = nextCID( NULL ); + cref = AddNew( cookie, connName, cid, langCode ); + m_db->AddNew( cookie, connName, cid, langCode, nPlayersT, nPlayersH ); } return cref; diff --git a/xwords4/relay/crefmgr.h b/xwords4/relay/crefmgr.h index 68abd0e51..527bfd6ba 100644 --- a/xwords4/relay/crefmgr.h +++ b/xwords4/relay/crefmgr.h @@ -25,6 +25,7 @@ #include #include "cref.h" +#include "dbmgr.h" #include "mlock.h" typedef map CookieMap; @@ -168,6 +169,8 @@ class CRefMgr { time_t m_startTime; string m_ports; + DBMgr* m_db; + friend class CookieMapIterator; }; /* CRefMgr */