diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index b80172b14..52c975c8d 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -417,7 +417,7 @@ comms_make( MPFORMAL XWEnv xwe, XW_UtilCtxt* util, XP_Bool isServer, XP_U16 forceChannel ) { CommsCtxt* comms = (CommsCtxt*)XP_CALLOC( mpool, sizeof(*comms) ); - MUTEX_INIT( &comms->mutex, XP_TRUE ); + MUTEX_INIT_CHECKED( &comms->mutex, XP_TRUE, 3 ); comms->util = util; comms->dutil = util_getDevUtilCtxt( util, xwe ); #ifdef DEBUG diff --git a/xwords4/common/xwmutex.c b/xwords4/common/xwmutex.c index 38ce2329d..26c65fce2 100644 --- a/xwords4/common/xwmutex.c +++ b/xwords4/common/xwmutex.c @@ -22,7 +22,13 @@ #ifdef DEBUG #include -#define WAIT_ALL_SECS 3 +// #define WAIT_ALL_SECS 3 +/* #define WAIT_ALL_SECS to enable checking for ALL mutexes, but don't do that + on Android because it kills the app (because locks in mpool are so + frequent, I suspect). I'll keep it on on Linux for testing, but even there + it limits how many games I can run at once. I really need a cleverer + implementation where a single thread checks everything.... +*/ /* What is this? It's my attempt to, on debug builds and for all or only chosen mutexes, get an assertion when the app doesn't get a lock in the @@ -95,9 +101,9 @@ mtx_lock_prv( MutexState* state, XP_U16 waitSecs, (void)pthread_create( &waitThread, NULL, checkLockProc, &ws ); int count = 0; while ( !ws.flagLoc ) { - usleep(50); /* wait for thread to start */ + usleep(500); /* wait for thread to start */ if ( 0 == (++count%10) ) { - XP_LOGFF( "count %d; flagLoc still null", count ); + // XP_LOGFF( "count %d; flagLoc still null", count ); } } } diff --git a/xwords4/linux/Makefile b/xwords4/linux/Makefile index 028976756..7bdb8f9a4 100644 --- a/xwords4/linux/Makefile +++ b/xwords4/linux/Makefile @@ -19,7 +19,8 @@ BUILD_DIR ?= . ifeq ($(MEMDEBUG),TRUE) -DEFINES = -DMEM_DEBUG -DDEBUG -DENABLE_LOGGING -DNUMBER_KEY_AS_INDEX +DEFINES = -DMEM_DEBUG -DDEBUG -DENABLE_LOGGING -DNUMBER_KEY_AS_INDEX +DEFINES += -DWAIT_ALL_SECS=3 DEFINES += -DLOG_COMMS_MSGNOS DEFINES += -DDI_DEBUG CFLAGS += -g $(GPROFFLAG) -Wall -Wunused-parameter -Wcast-align -Werror -O0