From d10d2597d40af1b5fca494e125d6eb88b61141f5 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 24 Aug 2020 16:16:20 -0700 Subject: [PATCH] add logging; cleanup I'm chasing a relay problem that's hard to repro and need more info when it's happened. (These won't show up in shipping builds.) --- .../java/org/eehouse/android/xw4/GameListGroup.java | 5 +++-- .../org/eehouse/android/xw4/jni/UtilCtxtImpl.java | 3 ++- xwords4/android/jni/xwjni.c | 12 ++++++------ xwords4/common/comms.c | 9 ++++++--- xwords4/common/game.c | 2 +- xwords4/common/server.c | 3 ++- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameListGroup.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameListGroup.java index ed0a8a951..bc340d536 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameListGroup.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameListGroup.java @@ -140,6 +140,7 @@ public class GameListGroup extends ExpiringLinearLayout ////////////////////////////////////////////////// // View.OnLongClickListener interface ////////////////////////////////////////////////// + @Override public boolean onLongClick( View view ) { boolean handled = ! XWApp.CONTEXT_MENUS_ENABLED; @@ -152,10 +153,10 @@ public class GameListGroup extends ExpiringLinearLayout ////////////////////////////////////////////////// // View.OnClickListener interface ////////////////////////////////////////////////// + @Override public void onClick( View view ) { - int id = view.getId(); - switch ( id ) { + switch ( view.getId() ) { case R.id.group_check: toggleSelected(); break; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/UtilCtxtImpl.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/UtilCtxtImpl.java index 97666e2d9..60d055d7b 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/UtilCtxtImpl.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/UtilCtxtImpl.java @@ -22,7 +22,7 @@ package org.eehouse.android.xw4.jni; import android.content.Context; - +import org.eehouse.android.xw4.Assert; import org.eehouse.android.xw4.Log; import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet; @@ -104,6 +104,7 @@ public class UtilCtxtImpl implements UtilCtxt { public void setIsServer( boolean isServer ) { subclassOverride( "setIsServer" ); + Assert.failDbg(); } @Override diff --git a/xwords4/android/jni/xwjni.c b/xwords4/android/jni/xwjni.c index 238da80f4..72595b0e1 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -1026,21 +1026,21 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1getInfo ( JNIEnv* env, jclass C, jlong jniGlobalPtr, jlong dictPtr, jboolean check ) { - jobject result = NULL; + jobject jinfo = NULL; #ifdef MAP_THREAD_TO_ENV JNIGlobalState* globalState = (JNIGlobalState*)jniGlobalPtr; MAP_THREAD( &globalState->ti, env ); #endif DictionaryCtxt* dict = (DictionaryCtxt*)dictPtr; if ( NULL != dict ) { - result = makeObjectEmptyConst( env, PKG_PATH("jni/DictInfo") ); + jinfo = makeObjectEmptyConst( env, PKG_PATH("jni/DictInfo") ); XP_LangCode code = dict_getLangCode( dict ); - setInt( env, result, "langCode", code ); - setInt( env, result, "wordCount", dict_getWordCount( dict, env ) ); - setString( env, result, "md5Sum", dict_getMd5Sum( dict ) ); + setInt( env, jinfo, "langCode", code ); + setInt( env, jinfo, "wordCount", dict_getWordCount( dict, env ) ); + setString( env, jinfo, "md5Sum", dict_getMd5Sum( dict ) ); } - return result; + return jinfo; } JNIEXPORT jstring JNICALL diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index 09fdb2880..f07f1639b 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -693,6 +693,7 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream, XW_UtilCtxt* uti } if ( addr_hasType(&addr, COMMS_CONN_RELAY ) ) { comms->rr.myHostID = stream_getU8( stream ); + XP_LOGFF( "loaded myHostID: %d", comms->rr.myHostID ); stringFromStreamHere( stream, comms->rr.connName, sizeof(comms->rr.connName) ); } @@ -920,6 +921,7 @@ comms_writeToStream( CommsCtxt* comms, XWEnv XP_UNUSED_DBG(xwe), stream_putU32( stream, comms->nextResend ); if ( addr_hasType( &comms->addr, COMMS_CONN_RELAY ) ) { stream_putU8( stream, comms->rr.myHostID ); + XP_LOGFF( "stored myHostID: %d", comms->rr.myHostID ); stringToStream( stream, comms->rr.connName ); } @@ -1747,12 +1749,14 @@ static void got_connect_cmd( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream, XP_Bool reconnected ) { + LOG_FUNC(); XP_U16 nHere, nSought; XP_Bool isServer; set_relay_state( comms, xwe, reconnected ? COMMS_RELAYSTATE_RECONNECTED : COMMS_RELAYSTATE_CONNECTED ); XWHostID myHostID = stream_getU8( stream ); + XP_LOGFF( "myHostID: %d", myHostID ); if ( comms->rr.myHostID != myHostID ) { XP_LOGF( "%s: changing rr.myHostID from %x to %x", __func__, comms->rr.myHostID, myHostID ); @@ -1815,7 +1819,7 @@ got_connect_cmd( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream, (*comms->procs.rconnd)( xwe, comms->procs.closure, comms->addr.u.ip_relay.invite, reconnected, comms->rr.myHostID, XP_FALSE, nSought - nHere ); - XP_LOGF( "%s: have %d of %d players", __func__, nHere, nSought ); + XP_LOGFF( "have %d of %d players", nHere, nSought ); } setHeartbeatTimer( comms ); } /* got_connect_cmd */ @@ -3160,8 +3164,7 @@ relay_msg_to_stream( CommsCtxt* comms, XWEnv xwe, XWRELAY_Cmd cmd, XWHostID dest stream_putU8( stream, comms->rr.myHostID ); XP_ASSERT( 0 < destID ); stream_putU8( stream, destID ); - XP_LOGF( "%s: wrote ids src %d, dest %d", __func__, - comms->rr.myHostID, destID ); + XP_LOGFF( "wrote ids src %d, dest %d", comms->rr.myHostID, destID ); if ( data != NULL && datalen > 0 ) { stream_putBytes( stream, data, datalen ); } diff --git a/xwords4/common/game.c b/xwords4/common/game.c index 60d7e1167..b6da2c7aa 100644 --- a/xwords4/common/game.c +++ b/xwords4/common/game.c @@ -83,7 +83,7 @@ makeGameID( XW_UtilCtxt* util ) /* High bit never set by XP_RANDOM() alone */ gameID = (XP_RANDOM() << 16) ^ XP_RANDOM(); } - LOG_RETURNF( "%x", gameID ); + LOG_RETURNF( "%x/%d", gameID, gameID ); return gameID; } diff --git a/xwords4/common/server.c b/xwords4/common/server.c index a2b269c41..f0c179280 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -696,7 +696,8 @@ XP_Bool server_initClientConnection( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream ) { XP_Bool result; - LOG_FUNC(); + XP_LOGFF( "gameState: %s; gameID: %d", getStateStr(server->nv.gameState), + server->vol.gi->gameID ); CurGameInfo* gi = server->vol.gi; XP_U16 nPlayers; LocalPlayer* lp;