mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 12:04:39 +02:00
8080225: FileInput/OutputStream/FileChannel cleanup should be improved
Reviewed-by: mchung, plevart, bpb
This commit is contained in:
parent
b93586c51e
commit
f29e21abb1
23 changed files with 1104 additions and 261 deletions
|
@ -114,6 +114,7 @@ class FileDispatcherImpl extends FileDispatcher {
|
|||
FileDescriptor result = new FileDescriptor();
|
||||
long handle = duplicateHandle(fdAccess.getHandle(fd));
|
||||
fdAccess.setHandle(result, handle);
|
||||
fdAccess.registerCleanup(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ public class WindowsAsynchronousFileChannelImpl
|
|||
invalidateAllLocks();
|
||||
|
||||
// close the file
|
||||
close0(handle);
|
||||
nd.close(fdObj);
|
||||
|
||||
// waits until all I/O operations have completed
|
||||
ioCache.close();
|
||||
|
@ -728,8 +728,6 @@ public class WindowsAsynchronousFileChannelImpl
|
|||
private static native int lockFile(long handle, long position, long size,
|
||||
boolean shared, long overlapped) throws IOException;
|
||||
|
||||
private static native void close0(long handle);
|
||||
|
||||
static {
|
||||
IOUtil.load();
|
||||
}
|
||||
|
|
|
@ -216,8 +216,7 @@ class WindowsChannelFactory {
|
|||
} catch (IOException x) {
|
||||
// IOException is thrown if the file handle cannot be associated
|
||||
// with the completion port. All we can do is close the file.
|
||||
long handle = fdAccess.getHandle(fdObj);
|
||||
CloseHandle(handle);
|
||||
fdAccess.close(fdObj);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
@ -347,6 +346,7 @@ class WindowsChannelFactory {
|
|||
FileDescriptor fdObj = new FileDescriptor();
|
||||
fdAccess.setHandle(fdObj, handle);
|
||||
fdAccess.setAppend(fdObj, flags.append);
|
||||
fdAccess.registerCleanup(fdObj);
|
||||
return fdObj;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue