6987116: (so) test/java/nio/channels/SocketChannel/VectorIO.java failed on Solaris 11
Reviewed-by: forax
This commit is contained in:
parent
0c5307c12b
commit
246920e930
@ -60,6 +60,7 @@ public class VectorIO {
|
|||||||
|
|
||||||
static void bufferTest(int port) throws Exception {
|
static void bufferTest(int port) throws Exception {
|
||||||
ByteBuffer[] bufs = new ByteBuffer[testSize];
|
ByteBuffer[] bufs = new ByteBuffer[testSize];
|
||||||
|
long total = 0L;
|
||||||
for(int i=0; i<testSize; i++) {
|
for(int i=0; i<testSize; i++) {
|
||||||
String source = "buffer" + i;
|
String source = "buffer" + i;
|
||||||
if (generator.nextBoolean())
|
if (generator.nextBoolean())
|
||||||
@ -69,6 +70,7 @@ public class VectorIO {
|
|||||||
|
|
||||||
bufs[i].put(source.getBytes("8859_1"));
|
bufs[i].put(source.getBytes("8859_1"));
|
||||||
bufs[i].flip();
|
bufs[i].flip();
|
||||||
|
total += bufs[i].remaining();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a connection to the server
|
// Get a connection to the server
|
||||||
@ -76,17 +78,20 @@ public class VectorIO {
|
|||||||
InetSocketAddress isa = new InetSocketAddress(lh, port);
|
InetSocketAddress isa = new InetSocketAddress(lh, port);
|
||||||
SocketChannel sc = SocketChannel.open();
|
SocketChannel sc = SocketChannel.open();
|
||||||
sc.connect(isa);
|
sc.connect(isa);
|
||||||
sc.configureBlocking(false);
|
sc.configureBlocking(generator.nextBoolean());
|
||||||
|
|
||||||
// Write the data out
|
// Write the data out
|
||||||
long bytesWritten = 0;
|
long rem = total;
|
||||||
do {
|
while (rem > 0L) {
|
||||||
bytesWritten = sc.write(bufs);
|
long bytesWritten = sc.write(bufs);
|
||||||
} while (bytesWritten > 0);
|
if (bytesWritten == 0) {
|
||||||
|
if (sc.isBlocking())
|
||||||
try {
|
throw new RuntimeException("write did not block");
|
||||||
Thread.currentThread().sleep(500);
|
Thread.sleep(50);
|
||||||
} catch (InterruptedException ie) { }
|
} else {
|
||||||
|
rem -= bytesWritten;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
sc.close();
|
sc.close();
|
||||||
@ -115,6 +120,7 @@ public class VectorIO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void bufferTest() throws Exception {
|
void bufferTest() throws Exception {
|
||||||
|
long total = 0L;
|
||||||
ByteBuffer[] bufs = new ByteBuffer[testSize];
|
ByteBuffer[] bufs = new ByteBuffer[testSize];
|
||||||
for(int i=0; i<testSize; i++) {
|
for(int i=0; i<testSize; i++) {
|
||||||
String source = "buffer" + i;
|
String source = "buffer" + i;
|
||||||
@ -122,6 +128,7 @@ public class VectorIO {
|
|||||||
bufs[i] = ByteBuffer.allocateDirect(source.length());
|
bufs[i] = ByteBuffer.allocateDirect(source.length());
|
||||||
else
|
else
|
||||||
bufs[i] = ByteBuffer.allocate(source.length());
|
bufs[i] = ByteBuffer.allocate(source.length());
|
||||||
|
total += bufs[i].capacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a connection from client
|
// Get a connection from client
|
||||||
@ -138,11 +145,21 @@ public class VectorIO {
|
|||||||
Thread.sleep(50);
|
Thread.sleep(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sc.configureBlocking(generator.nextBoolean());
|
||||||
|
|
||||||
// Read data into multiple buffers
|
// Read data into multiple buffers
|
||||||
long bytesRead = 0;
|
long avail = total;
|
||||||
do {
|
while (avail > 0) {
|
||||||
bytesRead = sc.read(bufs);
|
long bytesRead = sc.read(bufs);
|
||||||
} while (bytesRead > 0);
|
if (bytesRead < 0)
|
||||||
|
break;
|
||||||
|
if (bytesRead == 0) {
|
||||||
|
if (sc.isBlocking())
|
||||||
|
throw new RuntimeException("read did not block");
|
||||||
|
Thread.sleep(50);
|
||||||
|
}
|
||||||
|
avail -= bytesRead;
|
||||||
|
}
|
||||||
|
|
||||||
// Check results
|
// Check results
|
||||||
for(int i=0; i<testSize; i++) {
|
for(int i=0; i<testSize; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user