Log non-EPIPE I/O exceptions

On close, the client closes the socket. This wakes up socket blocking
calls on the server-side, by throwing an exception. Since this exception
is expected, it was not logged.

However, other IOExceptions might occur, which must not be ignored. For
that purpose, log only IOException when they are not caused by an EPIPE
error.
This commit is contained in:
Romain Vimont 2023-02-17 08:32:59 +01:00
parent 439a1fd4ed
commit f4e7085c34
2 changed files with 9 additions and 1 deletions

View file

@ -48,4 +48,9 @@ public final class IO {
} }
return builder.toString(); return builder.toString();
} }
public static boolean isBrokenPipe(IOException e) {
Throwable cause = e.getCause();
return cause instanceof ErrnoException && ((ErrnoException) cause).errno == OsConstants.EPIPE;
}
} }

View file

@ -110,7 +110,10 @@ public final class Server {
} }
screenEncoder.streamScreen(device, videoStreamer); screenEncoder.streamScreen(device, videoStreamer);
} catch (IOException e) { } catch (IOException e) {
// this is expected on close // Broken pipe is expected on close, because the socket is closed by the client
if (!IO.isBrokenPipe(e)) {
Ln.e("Video encoding error", e);
}
} finally { } finally {
Ln.d("Screen streaming stopped"); Ln.d("Screen streaming stopped");
initThread.interrupt(); initThread.interrupt();