From a8280a5d349a65d1323cffd540485498f276fd1e Mon Sep 17 00:00:00 2001 From: Neil Fuller Date: Wed, 31 Aug 2016 11:32:17 +0100 Subject: [PATCH] Fix receive timeout on LocalSocket The receive timeout stopped being set incorrect due to commit c80af6d8. There is an associated CTS regression test in cts/. Test: Ran CTS test android.net.cts.LocalSocketTest Bug: 31205169 Change-Id: I99808478946f8eae502c49d2cb83465648b9c904 --- core/java/android/net/LocalSocketImpl.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/core/java/android/net/LocalSocketImpl.java b/core/java/android/net/LocalSocketImpl.java index b83fb260d6f1..0f0e9c49a0b0 100644 --- a/core/java/android/net/LocalSocketImpl.java +++ b/core/java/android/net/LocalSocketImpl.java @@ -516,13 +516,11 @@ class LocalSocketImpl Os.setsockoptLinger(fd, OsConstants.SOL_SOCKET, OsConstants.SO_LINGER, linger); break; case SocketOptions.SO_TIMEOUT: - /* - * SO_TIMEOUT from the core library gets converted to - * SO_SNDTIMEO, but the option is supposed to set both - * send and receive timeouts. Note: The incoming timeout - * value is in milliseconds. - */ + // The option must set both send and receive timeouts. + // Note: The incoming timeout value is in milliseconds. StructTimeval timeval = StructTimeval.fromMillis(intValue); + Os.setsockoptTimeval(fd, OsConstants.SOL_SOCKET, OsConstants.SO_RCVTIMEO, + timeval); Os.setsockoptTimeval(fd, OsConstants.SOL_SOCKET, OsConstants.SO_SNDTIMEO, timeval); break; -- 2.11.0