mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-17 05:24:19 +01:00
Handle broken pipe errors specifically
Since 9555d3a537, a capture/encoding error
was sometimes logged on exit.
This commit is contained in:
@@ -72,4 +72,8 @@ public final class IO {
|
|||||||
Throwable cause = e.getCause();
|
Throwable cause = e.getCause();
|
||||||
return cause instanceof ErrnoException && ((ErrnoException) cause).errno == OsConstants.EPIPE;
|
return cause instanceof ErrnoException && ((ErrnoException) cause).errno == OsConstants.EPIPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isBrokenPipe(Exception e) {
|
||||||
|
return e instanceof IOException && isBrokenPipe((IOException) e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,10 @@ public class SurfaceEncoder implements AsyncProcessor {
|
|||||||
alive = !stopped.get() && !capture.isClosed();
|
alive = !stopped.get() && !capture.isClosed();
|
||||||
}
|
}
|
||||||
} catch (IllegalStateException | IllegalArgumentException | IOException e) {
|
} 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());
|
Ln.e("Capture/encoding error: " + e.getClass().getName() + ": " + e.getMessage());
|
||||||
if (!prepareRetry(size)) {
|
if (!prepareRetry(size)) {
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
Reference in New Issue
Block a user