mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 12:04:39 +02:00
8223442: java/nio/channels/SocketChannel/AdaptorStreams.java testConcurrentTimedReadWrite3(): failure
Reviewed-by: michaelm
This commit is contained in:
parent
bc264ba95b
commit
a817ac3456
5 changed files with 60 additions and 57 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,19 +25,16 @@
|
|||
|
||||
package sun.nio.ch;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Allows different platforms to call different native methods
|
||||
* for read and write operations.
|
||||
*/
|
||||
|
||||
class DatagramDispatcher extends NativeDispatcher
|
||||
{
|
||||
static {
|
||||
IOUtil.load();
|
||||
}
|
||||
class DatagramDispatcher extends NativeDispatcher {
|
||||
DatagramDispatcher() { }
|
||||
|
||||
int read(FileDescriptor fd, long address, int len) throws IOException {
|
||||
return read0(fd, address, len);
|
||||
|
@ -56,18 +53,24 @@ class DatagramDispatcher extends NativeDispatcher
|
|||
}
|
||||
|
||||
void close(FileDescriptor fd) throws IOException {
|
||||
SocketDispatcher.close0(fd);
|
||||
SocketDispatcher.invalidateAndClose(fd);
|
||||
}
|
||||
|
||||
static native int read0(FileDescriptor fd, long address, int len)
|
||||
// -- Native methods --
|
||||
|
||||
private static native int read0(FileDescriptor fd, long address, int len)
|
||||
throws IOException;
|
||||
|
||||
static native long readv0(FileDescriptor fd, long address, int len)
|
||||
private static native long readv0(FileDescriptor fd, long address, int len)
|
||||
throws IOException;
|
||||
|
||||
static native int write0(FileDescriptor fd, long address, int len)
|
||||
private static native int write0(FileDescriptor fd, long address, int len)
|
||||
throws IOException;
|
||||
|
||||
static native long writev0(FileDescriptor fd, long address, int len)
|
||||
private static native long writev0(FileDescriptor fd, long address, int len)
|
||||
throws IOException;
|
||||
|
||||
static {
|
||||
IOUtil.load();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,12 +28,18 @@ package sun.nio.ch;
|
|||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
|
||||
import jdk.internal.access.JavaIOFileDescriptorAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
|
||||
/**
|
||||
* Allows different platforms to call different native methods
|
||||
* for read and write operations.
|
||||
*/
|
||||
|
||||
class SocketDispatcher extends NativeDispatcher {
|
||||
private static final JavaIOFileDescriptorAccess fdAccess =
|
||||
SharedSecrets.getJavaIOFileDescriptorAccess();
|
||||
|
||||
SocketDispatcher() { }
|
||||
|
||||
int read(FileDescriptor fd, long address, int len) throws IOException {
|
||||
|
@ -53,30 +59,35 @@ class SocketDispatcher extends NativeDispatcher {
|
|||
}
|
||||
|
||||
void preClose(FileDescriptor fd) throws IOException {
|
||||
preClose0(fd);
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
void close(FileDescriptor fd) throws IOException {
|
||||
close0(fd);
|
||||
invalidateAndClose(fd);
|
||||
}
|
||||
|
||||
static void invalidateAndClose(FileDescriptor fd) throws IOException {
|
||||
assert fd.valid();
|
||||
int fdVal = fdAccess.get(fd);
|
||||
fdAccess.set(fd, -1);
|
||||
close0(fdVal);
|
||||
}
|
||||
|
||||
// -- Native methods --
|
||||
|
||||
static native int read0(FileDescriptor fd, long address, int len)
|
||||
private static native int read0(FileDescriptor fd, long address, int len)
|
||||
throws IOException;
|
||||
|
||||
static native long readv0(FileDescriptor fd, long address, int len)
|
||||
private static native long readv0(FileDescriptor fd, long address, int len)
|
||||
throws IOException;
|
||||
|
||||
static native int write0(FileDescriptor fd, long address, int len)
|
||||
private static native int write0(FileDescriptor fd, long address, int len)
|
||||
throws IOException;
|
||||
|
||||
static native long writev0(FileDescriptor fd, long address, int len)
|
||||
private static native long writev0(FileDescriptor fd, long address, int len)
|
||||
throws IOException;
|
||||
|
||||
static native void preClose0(FileDescriptor fd) throws IOException;
|
||||
|
||||
static native void close0(FileDescriptor fd) throws IOException;
|
||||
private static native void close0(int fdVal) throws IOException;
|
||||
|
||||
static {
|
||||
IOUtil.load();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue