Skip to content

Commit bef1998

Browse files
Merge pull request #54 from DmitryOlshansky/windows-io
Use *Ex file IO functions for use with IOCP
2 parents 35bb3c0 + ced633c commit bef1998

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/photon/windows/core.d

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,13 +787,14 @@ public @trusted nothrow {
787787
}
788788
overlapped.hEvent = ev;
789789
}
790-
if (!WriteFile(h, buf, cast(uint)count, null, &overlapped) && GetLastError() != ERROR_IO_PENDING) {
791-
return -1;
792-
}
793790
if (currentFiber) {
791+
if (!WriteFileEx(h, buf, cast(uint)count, &overlapped, null)) return -1;
794792
FiberExt.yield();
795793
return currentFiber.bytesTransfered;
796794
} else {
795+
if (!WriteFile(h, buf, cast(uint)count, null, &overlapped) && GetLastError() != ERROR_IO_PENDING) {
796+
return -1;
797+
}
797798
WaitForSingleObject(ev, INFINITE);
798799
return count;
799800
}
@@ -820,11 +821,12 @@ public @trusted nothrow {
820821
}
821822
overlapped.hEvent = ev;
822823
}
823-
if (!ReadFile(h, buf, cast(uint)count, null, &overlapped) && GetLastError() != ERROR_IO_PENDING) return -1;
824824
if (currentFiber) {
825+
if (!ReadFileEx(h, buf, cast(uint)count, &overlapped, null)) return -1;
825826
FiberExt.yield();
826827
return currentFiber.bytesTransfered;
827828
} else {
829+
if (!ReadFile(h, buf, cast(uint)count, null, &overlapped) && GetLastError() != ERROR_IO_PENDING) return -1;
828830
WaitForSingleObject(ev, INFINITE);
829831
return count;
830832
}

0 commit comments

Comments
 (0)