mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
always log stack of lock held more than 1 minute
(DEBUG only) I'm seeing deadlocks in a non-reproducible way and need to get at the source. This should log the stacks of long-held locks, and notify via Toast (when possible) when it occurs.
This commit is contained in:
parent
c757ba1386
commit
622fa53c64
1 changed files with 8 additions and 2 deletions
|
@ -261,11 +261,17 @@ public class GameLock implements AutoCloseable, Serializable {
|
|||
|
||||
private void logIfNull( GameLock result, String fmt, Object... args )
|
||||
{
|
||||
if ( DEBUG_LOCKS && null == result ) {
|
||||
if ( BuildConfig.DEBUG && null == result ) {
|
||||
String func = new Formatter().format( fmt, args ).toString();
|
||||
Log.d( TAG, "%s.%s => null", this, func );
|
||||
Owner curOwner = mOwners.peek();
|
||||
Log.d( TAG, "Unable to lock; cur owner: %s; would-be owner: %s",
|
||||
mOwners.peek(), new Owner() );
|
||||
curOwner, new Owner() );
|
||||
|
||||
long heldMS = System.currentTimeMillis() - curOwner.mStamp;
|
||||
if ( heldMS > (60 * 1000) ) { // 1 minute's a long time
|
||||
DbgUtils.showf( "GameLock: logged owner held for %d seconds!", heldMS / 1000 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue