mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
Merge remote-tracking branch 'origin/android_branch' into android_branch
This commit is contained in:
commit
385243763a
5 changed files with 24 additions and 11 deletions
|
@ -1969,7 +1969,7 @@ comms_canChat( const CommsCtxt* const comms )
|
|||
{
|
||||
XP_Bool canChat = comms_isConnected( comms )
|
||||
&& comms->connID != 0
|
||||
&& 128 > comms->queueLen;
|
||||
&& 64 > comms->queueLen;
|
||||
LOG_RETURNF( "%d", canChat );
|
||||
return canChat;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ HostRec(HostID hostID, const AddrInfo* addr, int nPlayersH, int seed, bool ackPe
|
|||
, m_lastHeartbeat(uptime())
|
||||
, m_ackPending(ackPending)
|
||||
{
|
||||
::logf( XW_LOGINFO, "created HostRec with id %d", m_hostID);
|
||||
logf( XW_LOGINFO, "%s created HostRec with id %d", __func__, m_hostID);
|
||||
}
|
||||
HostID m_hostID;
|
||||
AddrInfo m_addr;
|
||||
|
|
|
@ -199,11 +199,17 @@ UdpQueue::thread_main()
|
|||
pthread_mutex_unlock( &m_queueMutex );
|
||||
|
||||
utc->noteDequeued();
|
||||
logf( XW_LOGINFO, "%s: dispatching packet %d (socket %d); "
|
||||
"%d seconds old", __func__,
|
||||
utc->getID(), utc->addr()->socket() );
|
||||
(*utc->cb())( utc );
|
||||
utc->logStats();
|
||||
|
||||
time_t age = utc->ageInSeconds();
|
||||
if ( 30 > age ) {
|
||||
logf( XW_LOGINFO, "%s: dispatching packet %d (socket %d); "
|
||||
"%d seconds old", __func__, utc->getID(), utc->addr()->socket(),
|
||||
age );
|
||||
(*utc->cb())( utc );
|
||||
utc->logStats();
|
||||
} else {
|
||||
logf( XW_LOGINFO, "%s: dropping packet %d; it's %d seconds old!", age );
|
||||
}
|
||||
delete utc;
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
const AddrInfo* addr() const { return &m_addr; }
|
||||
void noteDequeued() { m_dequed = time( NULL ); }
|
||||
void logStats();
|
||||
time_t ageInSeconds() { return time( NULL ) - m_created; }
|
||||
const QueueCallback cb() const { return m_cb; }
|
||||
void setID( int id ) { m_id = id; }
|
||||
int getID( void ) { return m_id; }
|
||||
|
|
|
@ -1366,7 +1366,7 @@ ackPacketIf( const UDPHeader* header, const AddrInfo* addr )
|
|||
{
|
||||
if ( UDPAckTrack::shouldAck( header->cmd ) ) {
|
||||
uint32_t packetID = header->packetID;
|
||||
logf( XW_LOGINFO, "acking packet %d", packetID );
|
||||
logf( XW_LOGINFO, "%s: acking packet %d", __func__, packetID );
|
||||
packetID = htonl( packetID );
|
||||
send_via_udp( addr, XWPDEV_ACK,
|
||||
&packetID, sizeof(packetID), NULL );
|
||||
|
@ -1489,8 +1489,15 @@ read_udp_packet( int udpsock )
|
|||
|
||||
ssize_t nRead = recvfrom( udpsock, buf, sizeof(buf), 0 /*flags*/,
|
||||
&saddr.u.addr, &fromlen );
|
||||
logf( XW_LOGINFO, "%s: recvfrom=>%d", __func__, nRead );
|
||||
if ( 0 < nRead ) {
|
||||
#ifdef LOG_UDP_PACKETS
|
||||
gchar* b64 = g_base64_encode( (unsigned char*)&saddr, sizeof(saddr) );
|
||||
logf( XW_LOGINFO, "%s: recvfrom=>%d (saddr='%s')", __func__, nRead, b64 );
|
||||
g_free( b64 );
|
||||
#else
|
||||
logf( XW_LOGINFO, "%s: recvfrom=>%d", __func__, nRead );
|
||||
#endif
|
||||
|
||||
AddrInfo addr( udpsock, &saddr, false );
|
||||
UdpQueue::get()->handle( &addr, buf, nRead, handle_udp_packet );
|
||||
}
|
||||
|
@ -1989,8 +1996,7 @@ main( int argc, char** argv )
|
|||
|
||||
logf( XW_LOGINFO,
|
||||
"%s: accepting connection from %s on socket %d",
|
||||
__func__, inet_ntoa(saddr.u.addr_in.sin_addr),
|
||||
newSock );
|
||||
__func__, inet_ntoa(saddr.u.addr_in.sin_addr), newSock );
|
||||
|
||||
AddrInfo addr( newSock, &saddr, true );
|
||||
tPool->AddSocket( perGame ? XWThreadPool::STYPE_GAME
|
||||
|
|
Loading…
Reference in a new issue