mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
track and display in web view the number of games actually joined
rather than the number attempted.
This commit is contained in:
parent
f5ac51ae73
commit
8bb2fb9b09
4 changed files with 24 additions and 11 deletions
|
@ -617,6 +617,7 @@ CookieRef::handleEvents()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XWA_SENDALLHERE:
|
case XWA_SENDALLHERE:
|
||||||
|
CRefMgr::Get()->IncrementFullCount();
|
||||||
cancelAllConnectedTimer();
|
cancelAllConnectedTimer();
|
||||||
assignHostIds();
|
assignHostIds();
|
||||||
assignConnName();
|
assignConnName();
|
||||||
|
|
|
@ -61,6 +61,7 @@ CRefMgr::CRefMgr()
|
||||||
/* should be using pthread_once() here */
|
/* should be using pthread_once() here */
|
||||||
pthread_mutex_init( &m_SocketStuffMutex, NULL );
|
pthread_mutex_init( &m_SocketStuffMutex, NULL );
|
||||||
pthread_mutex_init( &m_nextCIDMutex, NULL );
|
pthread_mutex_init( &m_nextCIDMutex, NULL );
|
||||||
|
pthread_mutex_init( &m_roomsFilledMutex, NULL );
|
||||||
pthread_mutex_init( &m_freeList_mutex, NULL );
|
pthread_mutex_init( &m_freeList_mutex, NULL );
|
||||||
pthread_rwlock_init( &m_cookieMapRWLock, NULL );
|
pthread_rwlock_init( &m_cookieMapRWLock, NULL );
|
||||||
}
|
}
|
||||||
|
@ -210,13 +211,19 @@ CRefMgr::nextCID( const char* connName )
|
||||||
return ++m_nextCID;
|
return ++m_nextCID;
|
||||||
} /* nextCID */
|
} /* nextCID */
|
||||||
|
|
||||||
int
|
void
|
||||||
CRefMgr::GetNumGamesSeen( void )
|
CRefMgr::IncrementFullCount( void )
|
||||||
{
|
{
|
||||||
MutexLock ml(&m_nextCIDMutex);
|
MutexLock ml( &m_roomsFilledMutex );
|
||||||
return m_nextCID;
|
++m_nRoomsFilled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
CRefMgr::GetNumRoomsFilled( void )
|
||||||
|
{
|
||||||
|
MutexLock ml(&m_roomsFilledMutex);
|
||||||
|
return m_nRoomsFilled;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CRefMgr::GetSize( void )
|
CRefMgr::GetSize( void )
|
||||||
|
@ -227,7 +234,7 @@ CRefMgr::GetSize( void )
|
||||||
void
|
void
|
||||||
CRefMgr::GetStats( CrefMgrInfo& mgrInfo )
|
CRefMgr::GetStats( CrefMgrInfo& mgrInfo )
|
||||||
{
|
{
|
||||||
mgrInfo.m_nCrefsAll = GetNumGamesSeen();
|
mgrInfo.m_nRoomsFilled = GetNumRoomsFilled();
|
||||||
mgrInfo.m_startTimeSpawn = m_startTime;
|
mgrInfo.m_startTimeSpawn = m_startTime;
|
||||||
|
|
||||||
if ( 0 == m_ports.length() ) {
|
if ( 0 == m_ports.length() ) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ class CrefInfo {
|
||||||
class CrefMgrInfo {
|
class CrefMgrInfo {
|
||||||
public:
|
public:
|
||||||
const char* m_ports;
|
const char* m_ports;
|
||||||
int m_nCrefsAll;
|
int m_nRoomsFilled;
|
||||||
int m_nCrefsCurrent;
|
int m_nCrefsCurrent;
|
||||||
time_t m_startTimeSpawn;
|
time_t m_startTimeSpawn;
|
||||||
vector<CrefInfo> m_crefInfo;
|
vector<CrefInfo> m_crefInfo;
|
||||||
|
@ -108,7 +108,9 @@ class CRefMgr {
|
||||||
void PrintSocketInfo( int socket, string& out );
|
void PrintSocketInfo( int socket, string& out );
|
||||||
SocketsIterator MakeSocketsIterator();
|
SocketsIterator MakeSocketsIterator();
|
||||||
|
|
||||||
int GetNumGamesSeen( void );
|
void IncrementFullCount( void );
|
||||||
|
int GetNumRoomsFilled( void );
|
||||||
|
|
||||||
int GetSize( void );
|
int GetSize( void );
|
||||||
|
|
||||||
time_t uptime();
|
time_t uptime();
|
||||||
|
@ -153,6 +155,9 @@ class CRefMgr {
|
||||||
pthread_mutex_t m_nextCIDMutex;
|
pthread_mutex_t m_nextCIDMutex;
|
||||||
CookieID m_nextCID;
|
CookieID m_nextCID;
|
||||||
|
|
||||||
|
pthread_mutex_t m_roomsFilledMutex;
|
||||||
|
int m_nRoomsFilled;
|
||||||
|
|
||||||
pthread_rwlock_t m_cookieMapRWLock;
|
pthread_rwlock_t m_cookieMapRWLock;
|
||||||
CookieMap m_cookieMap;
|
CookieMap m_cookieMap;
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ send_meta( FILE* fil, const CrefMgrInfo* info )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( fil, "<title>relay: %d/%d</title>\n", info->m_nCrefsAll,
|
fprintf( fil, "<title>relay: %d/%d</title>\n", info->m_nRoomsFilled,
|
||||||
info->m_nCrefsCurrent );
|
info->m_nCrefsCurrent );
|
||||||
fprintf( fil, "</head>" );
|
fprintf( fil, "</head>" );
|
||||||
}
|
}
|
||||||
|
@ -189,11 +189,11 @@ printStats( FILE* fil, const CrefMgrInfo* info, bool isLocal )
|
||||||
fprintf( fil, "<table>" );
|
fprintf( fil, "<table>" );
|
||||||
fprintf( fil, "<tr>"
|
fprintf( fil, "<tr>"
|
||||||
"<th>Ports</th><th>Uptime</th><th>Spawns</th><th>Spawn Utime</th>"
|
"<th>Ports</th><th>Uptime</th><th>Spawns</th><th>Spawn Utime</th>"
|
||||||
"<th>Games played</th><th>Games in play</th></tr>" );
|
"<th>Rooms filled</th><th>Games in play</th></tr>" );
|
||||||
fprintf( fil, "<tr><td>%s</td><td>%s</td><td>%d</td>"
|
fprintf( fil, "<tr><td>%s</td><td>%s</td><td>%d</td>"
|
||||||
"<td>%s</td><td>%d</td><td>%d</td></tr>\n",
|
"<td>%s</td><td>%d</td><td>%d</td></tr>\n",
|
||||||
info->m_ports, uptime1, GetNSpawns(), uptime2, info->m_nCrefsAll,
|
info->m_ports, uptime1, GetNSpawns(), uptime2,
|
||||||
info->m_nCrefsCurrent );
|
info->m_nRoomsFilled, info->m_nCrefsCurrent );
|
||||||
fprintf( fil, "</table>" );
|
fprintf( fil, "</table>" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue