Prevent LocalSocket from creating an fd if fd is already there
Any LocalSocket created with a FileDescriptor will throw IOExceptions when performing most opperations due to the fact that the LocalSocket tries to create an implementation but fails since there is a FileDescriptor already set. Bug: 34095140 Test: Setup using tap&go Change-Id: Ie8f50def6156c16617697d939d6c0ab570281642
This commit is contained in:
@@ -73,6 +73,7 @@ public class LocalSocket implements Closeable {
|
||||
this(new LocalSocketImpl(fd), SOCKET_UNKNOWN);
|
||||
isBound = true;
|
||||
isConnected = true;
|
||||
implCreated = true;
|
||||
}
|
||||
|
||||
private LocalSocket(LocalSocketImpl impl, int sockType) {
|
||||
@@ -223,11 +224,11 @@ public class LocalSocket implements Closeable {
|
||||
implCreateIfNeeded();
|
||||
impl.shutdownOutput();
|
||||
}
|
||||
|
||||
|
||||
public void setReceiveBufferSize(int size) throws IOException {
|
||||
impl.setOption(SocketOptions.SO_RCVBUF, Integer.valueOf(size));
|
||||
}
|
||||
|
||||
|
||||
public int getReceiveBufferSize() throws IOException {
|
||||
return ((Integer) impl.getOption(SocketOptions.SO_RCVBUF)).intValue();
|
||||
}
|
||||
@@ -235,7 +236,7 @@ public class LocalSocket implements Closeable {
|
||||
public void setSoTimeout(int n) throws IOException {
|
||||
impl.setOption(SocketOptions.SO_TIMEOUT, Integer.valueOf(n));
|
||||
}
|
||||
|
||||
|
||||
public int getSoTimeout() throws IOException {
|
||||
return ((Integer) impl.getOption(SocketOptions.SO_TIMEOUT)).intValue();
|
||||
}
|
||||
@@ -243,7 +244,7 @@ public class LocalSocket implements Closeable {
|
||||
public void setSendBufferSize(int n) throws IOException {
|
||||
impl.setOption(SocketOptions.SO_SNDBUF, Integer.valueOf(n));
|
||||
}
|
||||
|
||||
|
||||
public int getSendBufferSize() throws IOException {
|
||||
return ((Integer) impl.getOption(SocketOptions.SO_SNDBUF)).intValue();
|
||||
}
|
||||
@@ -328,5 +329,5 @@ public class LocalSocket implements Closeable {
|
||||
*/
|
||||
public FileDescriptor getFileDescriptor() {
|
||||
return impl.getFileDescriptor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user