Summary: We currently give sonar one event base from java / obj-c code to use for scheduling tasks. This causes a problem, because we schedule reconnect tasks on the event base, and then these tasks interact with rsocket which schedules it's own tasks. The problem is that we're passing rsocket the same event base. So the reconnect code executes and blocks waiting for rsocket to connect. But rsocket can never connect because it never executes because that thread is blocked, so we get deadlock. Fixing it by giving both processes their own event base / thread. Reviewed By: danielbuechele Differential Revision: D8748354 fbshipit-source-id: aa00766059f66fadfecb1970492bbb7107bbbfe4
45 lines
893 B
Java
45 lines
893 B
Java
/*
|
|
* Copyright (c) 2004-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the LICENSE
|
|
* file in the root directory of this source tree.
|
|
*
|
|
*/
|
|
package com.facebook.sonar.android;
|
|
|
|
import android.os.Process;
|
|
import javax.annotation.Nullable;
|
|
|
|
class SonarThread extends Thread {
|
|
private @Nullable EventBase mEventBase;
|
|
|
|
SonarThread(final String name) {
|
|
super(name);
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
|
|
synchronized (this) {
|
|
try {
|
|
mEventBase = new EventBase();
|
|
} finally {
|
|
notifyAll();
|
|
}
|
|
}
|
|
|
|
mEventBase.loopForever();
|
|
}
|
|
|
|
synchronized EventBase getEventBase() {
|
|
while (mEventBase == null) {
|
|
try {
|
|
wait();
|
|
} catch (InterruptedException e) {
|
|
// ignore
|
|
}
|
|
}
|
|
return mEventBase;
|
|
}
|
|
}
|