From 0ac5d6d9e2a16cb51e8191176d96d5a9c21bf464 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 2 Jul 2013 18:30:23 -0700 Subject: [PATCH] don't send more than three unanswered chats per boot -- to avoid filling up the queues in a way that doesn't reflect real use. --- xwords4/linux/cursesmain.c | 8 ++++++-- xwords4/linux/cursesmain.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/xwords4/linux/cursesmain.c b/xwords4/linux/cursesmain.c index e87955aff..c3cd2eb44 100644 --- a/xwords4/linux/cursesmain.c +++ b/xwords4/linux/cursesmain.c @@ -1517,8 +1517,10 @@ curses_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo ) #ifdef XWFEATURE_CHAT static void -curses_util_showChat( XW_UtilCtxt* XP_UNUSED(uc), const XP_UCHAR* const msg ) +curses_util_showChat( XW_UtilCtxt* uc, const XP_UCHAR* const msg ) { + CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure; + globals->nChatsSent = 0; XP_LOGF( "%s: got \"%s\"", __func__, msg ); } #endif @@ -1721,7 +1723,8 @@ chatsTimerFired( gpointer data ) { CursesAppGlobals* globals = (CursesAppGlobals*)data; - if ( COMMS_RELAYSTATE_ALLCONNECTED == globals->commsRelayState ) { + if ( COMMS_RELAYSTATE_ALLCONNECTED == globals->commsRelayState + && 3 > globals->nChatsSent ) { XP_UCHAR msg[128]; struct tm* timp; struct timeval tv; @@ -1734,6 +1737,7 @@ chatsTimerFired( gpointer data ) timp->tm_hour, timp->tm_min, timp->tm_sec ); XP_LOGF( "%s: sending \"%s\"", __func__, msg ); server_sendChat( globals->cGlobals.game.server, msg ); + ++globals->nChatsSent; } return TRUE; diff --git a/xwords4/linux/cursesmain.h b/xwords4/linux/cursesmain.h index 99f771730..fa158471b 100644 --- a/xwords4/linux/cursesmain.h +++ b/xwords4/linux/cursesmain.h @@ -69,6 +69,8 @@ struct CursesAppGlobals { const struct MenuList* menuList; XP_U16 nLinesMenu; + XP_U16 nChatsSent; + union { struct { XWStreamCtxt* stream; /* how we can reach the server */