Fix adb forward initialization
In forward mode, the dummy byte must be written immediately after the
first accept(), otherwise the client will wait indefinitely, causing a
deadlock (or a timeout).
Regression introduced by 8c650e53cd
.
This commit is contained in:
parent
ea59d525bd
commit
b9315620e2
1 changed files with 13 additions and 11 deletions
|
@ -64,8 +64,6 @@ public final class DesktopConnection implements Closeable {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
String socketName = getSocketName(scid);
|
String socketName = getSocketName(scid);
|
||||||
|
|
||||||
LocalSocket firstSocket = null;
|
|
||||||
|
|
||||||
LocalSocket videoSocket = null;
|
LocalSocket videoSocket = null;
|
||||||
LocalSocket audioSocket = null;
|
LocalSocket audioSocket = null;
|
||||||
LocalSocket controlSocket = null;
|
LocalSocket controlSocket = null;
|
||||||
|
@ -74,23 +72,27 @@ public final class DesktopConnection implements Closeable {
|
||||||
try (LocalServerSocket localServerSocket = new LocalServerSocket(socketName)) {
|
try (LocalServerSocket localServerSocket = new LocalServerSocket(socketName)) {
|
||||||
if (video) {
|
if (video) {
|
||||||
videoSocket = localServerSocket.accept();
|
videoSocket = localServerSocket.accept();
|
||||||
firstSocket = videoSocket;
|
if (sendDummyByte) {
|
||||||
|
// send one byte so the client may read() to detect a connection error
|
||||||
|
videoSocket.getOutputStream().write(0);
|
||||||
|
sendDummyByte = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (audio) {
|
if (audio) {
|
||||||
audioSocket = localServerSocket.accept();
|
audioSocket = localServerSocket.accept();
|
||||||
if (firstSocket == null) {
|
if (sendDummyByte) {
|
||||||
firstSocket = audioSocket;
|
// send one byte so the client may read() to detect a connection error
|
||||||
|
audioSocket.getOutputStream().write(0);
|
||||||
|
sendDummyByte = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (control) {
|
if (control) {
|
||||||
controlSocket = localServerSocket.accept();
|
controlSocket = localServerSocket.accept();
|
||||||
if (firstSocket == null) {
|
|
||||||
firstSocket = controlSocket;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sendDummyByte) {
|
if (sendDummyByte) {
|
||||||
// send one byte so the client may read() to detect a connection error
|
// send one byte so the client may read() to detect a connection error
|
||||||
firstSocket.getOutputStream().write(0);
|
controlSocket.getOutputStream().write(0);
|
||||||
|
sendDummyByte = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue