instantiate and use the new dbmgr class

This commit is contained in:
Eric House 2010-09-11 19:45:04 -07:00
parent 87de53cf96
commit c1da64b96a
2 changed files with 9 additions and 1 deletions

View file

@ -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;

View file

@ -25,6 +25,7 @@
#include <list>
#include "cref.h"
#include "dbmgr.h"
#include "mlock.h"
typedef map<CookieID,CookieRef*> CookieMap;
@ -168,6 +169,8 @@ class CRefMgr {
time_t m_startTime;
string m_ports;
DBMgr* m_db;
friend class CookieMapIterator;
}; /* CRefMgr */