Skip to content

Commit 60cc84b

Browse files
committed
wip
1 parent 4855c5e commit 60cc84b

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

src/main/java/jnr/enxio/channels/NativeSocketChannel.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ public void setFD(int fd) {
5252

5353
@Override
5454
protected void implCloseSelectableChannel() throws IOException {
55+
System.out.println("implCloseSelectableChannel");
5556
Native.close(fd);
5657
}
5758

5859
@Override
5960
protected void implConfigureBlocking(boolean block) throws IOException {
61+
System.out.println("implConfigureBlocking: " + block);
6062
Native.setBlocking(fd, block);
6163
}
6264

@@ -99,10 +101,21 @@ public int read(ByteBuffer dst) throws IOException {
99101

100102
public int write(ByteBuffer src) throws IOException {
101103

102-
System.out.println("write: " + hexDump(src, ""));
104+
System.err.println("write:");
105+
//System.err.println(hexDump(src, ""));
106+
107+
ByteBuffer buffer = ByteBuffer.allocate(src.remaining());
108+
109+
buffer.put(src);
110+
111+
buffer.position(0);
112+
113+
int n = Native.write(fd, buffer);
114+
115+
System.err.println(Native.getLastErrorString());
103116

104-
int n = Native.write(fd, src);
105117
if (n < 0) {
118+
System.err.println("write error");
106119
throw new IOException(Native.getLastErrorString());
107120
}
108121

src/main/java/jnr/unixsocket/UnixSocketChannel.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static final UnixSocketChannel open(UnixSocketAddress remote) throws IOEx
6969
public static final UnixSocketChannel create() throws IOException {
7070
UnixSocketChannel channel = new UnixSocketChannel();
7171
// channel.configureBlocking(true);
72-
// channel.socket().setKeepAlive(true);
72+
//channel.socket().setKeepAlive(true);
7373
return channel;
7474
}
7575

@@ -140,7 +140,7 @@ public boolean connect(UnixSocketAddress remote) throws IOException {
140140
}
141141

142142
public boolean isConnected() {
143-
System.out.println("isConnected: " + state);
143+
//System.out.println("isConnected: " + state);
144144
return state == State.CONNECTED;
145145
}
146146

@@ -257,16 +257,19 @@ public SocketAddress getLocalAddress() throws IOException {
257257

258258
@Override
259259
public <T> T getOption(java.net.SocketOption<T> arg0) throws IOException {
260+
System.err.println("getOption unsupported");
260261
throw new UnsupportedOperationException("getOption");
261262
}
262263

263264
@Override
264265
public Set<java.net.SocketOption<?>> supportedOptions() {
266+
System.err.println("supportedOptions unsupported");
265267
throw new UnsupportedOperationException("supportedOptions");
266268
}
267269

268270
@Override
269271
public SocketChannel bind(SocketAddress local) throws IOException {
272+
System.err.println("bind unsupported");
270273
throw new UnsupportedOperationException("bind");
271274
}
272275

@@ -292,6 +295,7 @@ public long read(ByteBuffer[] dsts, int offset, int length) throws IOException {
292295

293296
@Override
294297
public <T> SocketChannel setOption(java.net.SocketOption<T> name, T value) throws IOException {
298+
System.err.println("setOption unsupported");
295299
throw new UnsupportedOperationException("setOption");
296300
}
297301

@@ -319,17 +323,18 @@ public long write(ByteBuffer[] srcs, int offset, int length) throws IOException
319323
System.out.println("remaining: " + remaining);
320324

321325

322-
ByteBuffer buffer = ByteBuffer.allocate(remaining);
326+
//ByteBuffer buffer = ByteBuffer.allocate(remaining);
323327

324328
for (index = offset; index < length; index++) {
325-
buffer.put(srcs[index]);
329+
//buffer.put(srcs[index]);
330+
System.err.println("bulk write: " + index);
331+
//System.err.println(hexDump(srcs[index], ""));
332+
result += write(srcs[index]);
326333
}
327334

328-
buffer.position(0);
335+
//buffer.position(0);
329336

330-
System.out.println("buffer.remaining: " + buffer.remaining());
331-
332-
result = write(buffer);
337+
//result = write(buffer);
333338
System.out.println("finally written: " + result);
334339

335340
return result;

src/test/java/com/github/dockerjava/netty/exec/AttachContainerCmdExecTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void attachContainerWithStdin() throws Exception {
8181

8282
String snippet = "hello world!";
8383

84-
CreateContainerResponse container = dockerClient.createContainerCmd("busybox").withCmd("/bin/sh", "-c", "echo running >> /tmp/attach && read line && echo $line > /tmp/attach && sleep 9999")
84+
CreateContainerResponse container = dockerClient.createContainerCmd("busybox").withCmd("/bin/sh", "-c", "read line && echo $line && sleep 9999")
8585
.withTty(false).withStdinOpen(true).exec();
8686

8787
LOG.info("Created container: {}", container.toString());
@@ -102,10 +102,10 @@ public void onNext(Frame frame) {
102102
};
103103
};
104104

105-
InputStream stdin = new ByteArrayInputStream((snippet + "\n").getBytes());
105+
InputStream stdin = new ByteArrayInputStream((snippet + "\n\r").getBytes());
106106

107107
dockerClient.attachContainerCmd(container.getId()).withStdErr(true).withStdOut(true).withFollowStream(true)
108-
.withStdIn(stdin).exec(callback).awaitCompletion(5, TimeUnit.MINUTES);
108+
.withStdIn(stdin).exec(callback).awaitCompletion(5, TimeUnit.SECONDS);
109109
callback.close();
110110

111111
assertThat(callback.toString(), containsString(snippet));

0 commit comments

Comments
 (0)