From 085963b76ca834a1dbaa07f18712516859692d13 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 9 Mar 2019 06:40:04 -0800 Subject: [PATCH] unlock lock we won't be keeping This might fix the occasional game permalock. --- .../main/java/org/eehouse/android/xw4/BoardDelegate.java | 2 +- .../main/java/org/eehouse/android/xw4/jni/JNIThread.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java index c8eb9826d..e3bcdb9ae 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java @@ -581,7 +581,7 @@ public class BoardDelegate extends DelegateBase m_haveInvited = args.getBoolean( GameUtils.INVITED, false ); m_overNotShown = true; - GameLock.getLockThen( m_rowid, 100L, new Handler(), + GameLock.getLockThen( m_rowid, 100L, new Handler(), // this doesn't unlock new GameLock.GotLockProc() { @Override public void gotLock( GameLock lock ) { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/JNIThread.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/JNIThread.java index 8a895950b..102fd6898 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/JNIThread.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/JNIThread.java @@ -866,6 +866,14 @@ public class JNIThread extends Thread implements AutoCloseable { if ( null == result && null != lock ) { result = new JNIThread( lock ); s_instances.put( rowid, result ); + } else if ( null != lock ) { + // unlock if we're not using it. This is a hack needed because + // we don't have retain/release semantics. The caller is done + // with the lock and expects us to keep it. If we don't need + // it we need to unlock it. Fix is for JNIThread.__init() to + // be able to retain() it and caller to release() it after we + // return. + lock.unlock(); } if ( null != result ) { result.retain_sync();