Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjfrijters <jfrijters>2008-04-14 09:08:24 +0400
committerjfrijters <jfrijters>2008-04-14 09:08:24 +0400
commit233dfedc696d8ec619bf0c7ea21716a9d2e816a2 (patch)
treee7daf4e94cdf0570c4f83982b709252fc5fd3ea6 /openjdk/sun/nio/ch
parent2e60f0611f4cd8920a2749412d62febb37d95053 (diff)
- Fixed memory mapped file bug that caused mapping at non-zero file position to fail.
- Close mapping handle using the Close() method on SafeFileHanlde instead of p/invoking the Win32 API directly.
Diffstat (limited to 'openjdk/sun/nio/ch')
-rw-r--r--openjdk/sun/nio/ch/FileChannelImpl.java8
1 files changed, 3 insertions, 5 deletions
diff --git a/openjdk/sun/nio/ch/FileChannelImpl.java b/openjdk/sun/nio/ch/FileChannelImpl.java
index 0aeaa9a3..b63da1bd 100644
--- a/openjdk/sun/nio/ch/FileChannelImpl.java
+++ b/openjdk/sun/nio/ch/FileChannelImpl.java
@@ -1358,7 +1358,8 @@ public class FileChannelImpl
throw new Error();
}
- SafeFileHandle hFileMapping = CreateFileMapping(fs.get_SafeFileHandle(), IntPtr.Zero, fileProtect, (int)(length >> 32), (int)length, null);
+ long maxSize = length + position;
+ SafeFileHandle hFileMapping = CreateFileMapping(fs.get_SafeFileHandle(), IntPtr.Zero, fileProtect, (int)(maxSize >> 32), (int)maxSize, null);
int err = cli.System.Runtime.InteropServices.Marshal.GetLastWin32Error();
if (hFileMapping.get_IsInvalid())
{
@@ -1366,7 +1367,7 @@ public class FileChannelImpl
}
IntPtr p = MapViewOfFile(hFileMapping, mapAccess, (int)(position >> 32), (int)position, IntPtr.op_Explicit(length));
err = cli.System.Runtime.InteropServices.Marshal.GetLastWin32Error();
- CloseHandle(hFileMapping);
+ hFileMapping.Close();
if (p.Equals(IntPtr.Zero))
{
if (err == 8 /*ERROR_NOT_ENOUGH_MEMORY*/)
@@ -1427,9 +1428,6 @@ public class FileChannelImpl
@DllImportAttribute.Annotation("kernel32")
private static native int FlushFileBuffers(SafeFileHandle handle);
- @DllImportAttribute.Annotation("kernel32")
- private static native int CloseHandle(SafeFileHandle handle);
-
@DllImportAttribute.Annotation(value="kernel32", SetLastError=true)
private static native SafeFileHandle CreateFileMapping(SafeFileHandle hFile, IntPtr lpAttributes, int flProtect, int dwMaximumSizeHigh, int dwMaximumSizeLow, String lpName);