8053931: (fc) FileDispatcherImpl.lock0 does not handle ERROR_IO_PENDING [win]
authoralanb
Fri, 01 Aug 2014 15:50:01 +0100
changeset 25806 7a0cf527248e
parent 25805 0bc2aa4aadbe
child 25807 6c325960c9ee
8053931: (fc) FileDispatcherImpl.lock0 does not handle ERROR_IO_PENDING [win] Reviewed-by: alanb Contributed-by: martin.doerr@sap.com
jdk/src/windows/native/sun/nio/ch/FileDispatcherImpl.c
--- a/jdk/src/windows/native/sun/nio/ch/FileDispatcherImpl.c	Fri Aug 01 15:36:23 2014 +0100
+++ b/jdk/src/windows/native/sun/nio/ch/FileDispatcherImpl.c	Fri Aug 01 15:50:01 2014 +0100
@@ -406,6 +406,14 @@
     result = LockFileEx(h, flags, 0, lowNumBytes, highNumBytes, &o);
     if (result == 0) {
         int error = GetLastError();
+        if (error == ERROR_IO_PENDING) {
+            LPDWORD dwBytes;
+            result = GetOverlappedResult(h, &o, &dwBytes, TRUE);
+            if (result != 0) {
+                return sun_nio_ch_FileDispatcherImpl_LOCKED;
+            }
+            error = GetLastError();
+        }
         if (error != ERROR_LOCK_VIOLATION) {
             JNU_ThrowIOExceptionWithLastError(env, "Lock failed");
             return sun_nio_ch_FileDispatcherImpl_NO_LOCK;