Skip to content

Commit 9092ba2

Browse files
committed
haha: haha
haha Signed-off-by: Peng Tao <[email protected]>
1 parent 3c287ec commit 9092ba2

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

docker-java-transport/src/main/java/com/github/dockerjava/transport/DomainSocket.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
import java.nio.ByteBuffer;
2424

2525
import com.github.dockerjava.transport.FileDescriptor.Handle;
26+
import com.sun.jna.ptr.IntByReference;
2627
import com.sun.jna.LastErrorException;
28+
import com.sun.jna.Pointer;
2729
import com.sun.jna.Native;
2830
import com.sun.jna.Platform;
2931

@@ -66,6 +68,10 @@ public abstract class DomainSocket extends AbstractSocket {
6668

6769
private FileDescriptor open(String path) {
6870
int handle = socket(PF_LOCAL, SOCK_STREAM, 0);
71+
setsockopt(handle, 1/*SOL_SOCKET*/, 20/*SO_RCVTIMEO*/, new IntByReference(1000).getPointer(), 4);
72+
setsockopt(handle, 1/*SOL_SOCKET*/, 21/*SO_SNDTIMEO*/, new IntByReference(1000).getPointer(), 4);
73+
setsockopt(handle, 1/*SOL_SOCKET*/, 66/*SO_RCVTIMEO_NEW*/, new IntByReference(1000).getPointer(), 4);
74+
setsockopt(handle, 1/*SOL_SOCKET*/, 67/*SO_SNDTIMEO_NEW*/, new IntByReference(1000).getPointer(), 4);
6975
connect(path, handle);
7076
return new FileDescriptor(handle, this::close);
7177
}
@@ -119,6 +125,8 @@ public void close() throws IOException {
119125

120126
private native int socket(int domain, int type, int protocol) throws LastErrorException;
121127

128+
private static native int setsockopt(int fd, int level, int option, Pointer value, int len) throws LastErrorException;
129+
122130
private native int read(int fd, ByteBuffer buffer, int count) throws LastErrorException;
123131

124132
private native int write(int fd, ByteBuffer buffer, int count) throws LastErrorException;

0 commit comments

Comments
 (0)