Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support deadlock detection on android #250

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/main/java/org/bitcoinj/evolution/QuorumState.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ public void processDiff(@Nullable Peer peer, SimplifiedMasternodeListDiff mnlist

lock.lock();
try {
log.info("lock acquired when processing mnlistdiff");
applyDiff(peer, blockChain, mnlistdiff, isLoadingBootStrap);

log.info(this.toString());
Expand Down
7 changes: 6 additions & 1 deletion core/src/main/java/org/bitcoinj/utils/Threading.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,19 @@

private static CycleDetectingLockFactory.Policy policy;
public static CycleDetectingLockFactory factory;
private static boolean useDefaultAndroidPolicy = true;

public static ReentrantLock lock(String name) {
if (Utils.isAndroidRuntime())
if (Utils.isAndroidRuntime() && useDefaultAndroidPolicy)
return new ReentrantLock(true);
else
return factory.newReentrantLock(name);
}

public static void setUseDefaultAndroidPolicy(boolean use) {
useDefaultAndroidPolicy = use;
}

Check warning on line 163 in core/src/main/java/org/bitcoinj/utils/Threading.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/bitcoinj/utils/Threading.java#L162-L163

Added lines #L162 - L163 were not covered by tests

public static void warnOnLockCycles() {
setPolicy(CycleDetectingLockFactory.Policies.WARN);
}
Expand Down
Loading