Skip to content

Commit 5c3626e

Browse files
committed
Handle broken pipe errors specifically
Since 9555d3a, a capture/encoding error was sometimes logged on exit.
1 parent 0e473eb commit 5c3626e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

server/src/main/java/com/genymobile/scrcpy/util/IO.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,8 @@ public static boolean isBrokenPipe(IOException e) {
7272
Throwable cause = e.getCause();
7373
return cause instanceof ErrnoException && ((ErrnoException) cause).errno == OsConstants.EPIPE;
7474
}
75+
76+
public static boolean isBrokenPipe(Exception e) {
77+
return e instanceof IOException && isBrokenPipe((IOException) e);
78+
}
7579
}

server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ private void streamCapture() throws IOException, ConfigurationException {
113113
alive = !stopped.get() && !capture.isClosed();
114114
}
115115
} catch (IllegalStateException | IllegalArgumentException | IOException e) {
116+
if (IO.isBrokenPipe(e)) {
117+
// Do not retry on broken pipe, which is expected on close because the socket is closed by the client
118+
throw e;
119+
}
116120
Ln.e("Capture/encoding error: " + e.getClass().getName() + ": " + e.getMessage());
117121
if (!prepareRetry(size)) {
118122
throw e;

0 commit comments

Comments
 (0)