OSDN Git Service

SSLSocket should respect timeout of a wrapped Socket
authorBrian Carlstrom <bdc@google.com>
Sun, 19 Sep 2010 04:16:01 +0000 (21:16 -0700)
committerBrian Carlstrom <bdc@google.com>
Sun, 19 Sep 2010 17:51:58 +0000 (10:51 -0700)
commita4a95792af235d4bf3256eab3208f74fae8ec262
tree3485a33d5c1f4d128519d3a3463d11a4f58e5b07
parentac277be6a146ade8f150236edf730431a7e12482
SSLSocket should respect timeout of a wrapped Socket

Change to using getSoTimeout in OpenSSLSocketImpl instead of directly
using the timeout field. This means the proper timeout will be used
for instances of the OpenSSLSocketImplWrapper subclass, which is used
when an SSLSocket is wrapped around an existing connected non-SSL
Socket. The code still maintains the local timeout field, now renamed
timeoutMilliseconds, which is now accesed via
OpenSSLSocketImpl.getSoTimeout. Doing so prevents a getsockopt syscall
that otherwise would be necessary if the super.getSoTimeout() was used.

Added two unit tests for testing timeouts with SSLSockets wrapped
around Socket. One is simply for getters/setters. The second makes
sure the timeout is functioning when set on the underlying socket.

Bug: 2973305
Change-Id: Idac52853f5d777fae5060a840eefbfe85d448e4c
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java