(but note: I don't
have a Windows dev environment!).
Not having an environment to test shows: as it turns out, WriteFile
returns a BOOL, not a DWORD, meaning that the patch below is much more
applicable. I hope it's good enough now. (BTW, the patch requires the
'-p2' parameter for patch(1) to apply correctly.)
Index: ../apr/file_io/win32/readwrite.c
===================================================================
--- ../apr/file_io/win32/readwrite.c (revision 518377)
+++ ../apr/file_io/win32/readwrite.c (working copy)
@@ -310,15 +310,25 @@
thefile->pOverlapped->Offset = (DWORD)thefile->filePtr;
thefile->pOverlapped->OffsetHigh =
(DWORD)(thefile->filePtr >> 32);
}
- rv = WriteFile(thefile->filehand, buf, (DWORD)*nbytes, &bwrote,
- thefile->pOverlapped);
+
+ if (!(rv = WriteFile(thefile->filehand, buf, (DWORD)*nbytes,
+ &bwrote, thefile->pOverlapped))
+ && GetLastError() == ERROR_INSUFFICIENT_BUFFER
+ && *nbytes > (30*1024))
+ rv = WriteFile(thefile->filehand, buf,
(DWORD)(30*1024), &bwrote,+
thefile->pOverlapped);
+
if (thefile->append) {
apr_file_unlock(thefile);
apr_thread_mutex_unlock(thefile->mutex);
}
}
else {
- rv = WriteFile(thefile->filehand, buf, (DWORD)*nbytes, &bwrote,
+ if (!(rv = WriteFile(thefile->filehand, buf,
(DWORD)*nbytes, &bwrote,+
thefile->pOverlapped))
+ && GetLastError() == ERROR_INSUFFICIENT_BUFFER
+ && *nbytes > (30*1024))
+ rv = WriteFile(thefile->filehand, buf, (DWORD)(30*1024), &bwrote,
thefile->pOverlapped);
}
if (rv) {
@@ -478,6 +488,8 @@
bytesleft = thefile->bufpos;
do {
+ DWORD rv;
+
if (bytesleft > APR_DWORD_MAX) {
numbytes = APR_DWORD_MAX;
}
@@ -485,7 +497,14 @@
numbytes = (DWORD)bytesleft;
}
- if (!WriteFile(thefile->filehand, buffer, numbytes,
&written, NULL)) {
+ if (!(rv = WriteFile(thefile->filehand, buffer, numbytes,
+ &written, NULL))
+ && GetLastError() == ERROR_INSUFFICIENT_BUFFER
+ && numbytes > (30*1024))
+ rv = WriteFile(thefile->filehand, buffer, (DWORD)(30*1024),
+ &bwrote, NULL);
+
+ if (!rv)
rc = apr_get_os_error();
thefile->filePtr += written;
break;
bye,
Erik.