diff options
author | Elliott Hughes <enh@google.com> | 2011-03-30 15:35:16 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2011-03-30 16:31:35 -0700 |
commit | 0a9d1ee45a9884a9616624d747172e18734e8fe0 (patch) | |
tree | 3e4caa7557a2dd2c2415f7c34cfcddb804d91e2b /dalvik | |
parent | e8fad0e2a8787fd46654d1cc9e477b353a958451 (diff) | |
download | libcore-0a9d1ee45a9884a9616624d747172e18734e8fe0.zip libcore-0a9d1ee45a9884a9616624d747172e18734e8fe0.tar.gz libcore-0a9d1ee45a9884a9616624d747172e18734e8fe0.tar.bz2 |
Add getsockname(2) and getsockopt(2).
Bug: 3107501
Change-Id: Ibb0d5a576ecb46e51dbda6051776145eec9e7fe1
Diffstat (limited to 'dalvik')
-rw-r--r-- | dalvik/src/main/java/dalvik/system/BlockGuard.java | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/dalvik/src/main/java/dalvik/system/BlockGuard.java b/dalvik/src/main/java/dalvik/system/BlockGuard.java index 56abeb8..d3c5088 100644 --- a/dalvik/src/main/java/dalvik/system/BlockGuard.java +++ b/dalvik/src/main/java/dalvik/system/BlockGuard.java @@ -24,7 +24,10 @@ import java.net.InetAddress; import java.net.SocketException; import java.net.SocketImpl; import java.net.SocketOptions; +import libcore.io.Libcore; +import libcore.io.StructLinger; import org.apache.harmony.luni.platform.INetworkSystem; +import static libcore.io.OsConstants.*; /** * Mechanism to let threads set restrictions on what code is allowed @@ -254,10 +257,6 @@ public final class BlockGuard { mNetwork.connect(aFD, inetAddress, port, timeout); } - public InetAddress getSocketLocalAddress(FileDescriptor aFD) { - return mNetwork.getSocketLocalAddress(aFD); - } - public boolean select(FileDescriptor[] readFDs, FileDescriptor[] writeFDs, int numReadable, int numWritable, long timeout, int[] flags) throws SocketException { @@ -265,15 +264,6 @@ public final class BlockGuard { return mNetwork.select(readFDs, writeFDs, numReadable, numWritable, timeout, flags); } - public int getSocketLocalPort(FileDescriptor aFD) { - return mNetwork.getSocketLocalPort(aFD); - } - - public Object getSocketOption(FileDescriptor aFD, int opt) - throws SocketException { - return mNetwork.getSocketOption(aFD, opt); - } - public void setSocketOption(FileDescriptor aFD, int opt, Object optVal) throws SocketException { mNetwork.setSocketOption(aFD, opt, optVal); @@ -291,13 +281,8 @@ public final class BlockGuard { private boolean isLingerSocket(FileDescriptor fd) throws SocketException { try { - Object lingerValue = mNetwork.getSocketOption(fd, SocketOptions.SO_LINGER); - if (lingerValue instanceof Boolean) { - return (Boolean) lingerValue; - } else if (lingerValue instanceof Integer) { - return ((Integer) lingerValue) != 0; - } - throw new AssertionError(lingerValue.getClass().getName()); + StructLinger linger = Libcore.os.getsockoptLinger(fd, SOL_SOCKET, SO_LINGER); + return linger.isOn() && linger.l_linger > 0; } catch (Exception ignored) { // We're called via Socket.close (which doesn't ask for us to be called), so we // must not throw here, because Socket.close must not throw if asked to close an |