From 272f8a39601e814146ede3b6b4290cc861184114 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 26 Jul 2016 07:27:13 -0700 Subject: [PATCH] don't bother saving if no data loaded yet Fixes, or at least makes extremely unlikely, race condition where one thread makes use of an existing JNIThread instance then releases it before the thread that created it has had a chance to call configure() to actually load the game. --- xwords4/android/XWords4/jni/xwjni.c | 1 + .../XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 87f8c8596..0ce880051 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -1261,6 +1261,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1do { jboolean result; XWJNI_START(); + XP_ASSERT( !!state->game.server ); result = server_do( state->game.server ); XWJNI_END(); return result; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java index 04fc49e7c..dd087a0cd 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java @@ -766,7 +766,7 @@ public class JNIThread extends Thread { if ( stop ) { waitToStop( true ); - } else { + } else if ( null != m_lastSavedState ) { // has configure() run? handle( JNICmd.CMD_SAVE ); // in case releaser has made changes } }