Display and control your Android device
Handle broken pipe errors specifically
Romain Vimont5c3626ed47b9
diff --git a/server/src/main/java/com/genymobile/scrcpy/util/IO.java b/server/src/main/java/com/genymobile/scrcpy/util/IO.javaindex b953f290..16ddaedd 100644--- a/server/src/main/java/com/genymobile/scrcpy/util/IO.java+++ b/server/src/main/java/com/genymobile/scrcpy/util/IO.java@@ -72,4 +72,8 @@ public final class IO {Throwable cause = e.getCause();return cause instanceof ErrnoException && ((ErrnoException) cause).errno == OsConstants.EPIPE;}++ public static boolean isBrokenPipe(Exception e) {+ return e instanceof IOException && isBrokenPipe((IOException) e);+ }}diff --git a/server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java b/server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.javaindex 1402eceb..236a5f48 100644--- a/server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java+++ b/server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java@@ -113,6 +113,10 @@ public class SurfaceEncoder implements AsyncProcessor {alive = !stopped.get() && !capture.isClosed();}} catch (IllegalStateException | IllegalArgumentException | IOException e) {+ if (IO.isBrokenPipe(e)) {+ // Do not retry on broken pipe, which is expected on close because the socket is closed by the client+ throw e;+ }Ln.e("Capture/encoding error: " + e.getClass().getName() + ": " + e.getMessage());if (!prepareRetry(size)) {throw e;