2735 Vladislav Vaintroub 2008-07-08
WL#3998 - Falcon positioned IO.
Use the native windows functionality to do positioned IO
and eliminate the need of read/write/seek synchronization
modified:
storage/falcon/IO.cpp
storage/falcon/SerialLogFile.cpp
2734 Vladislav Vaintroub 2008-07-08
Correct compile warning - passing JString as parameter to printf , instead
of char *
modified:
storage/falcon/IO.cpp
=== modified file 'storage/falcon/IO.cpp'
--- a/storage/falcon/IO.cpp 2008-07-08 19:27:41 +0000
+++ b/storage/falcon/IO.cpp 2008-07-08 21:36:34 +0000
@@ -528,6 +528,17 @@ int IO::pread(int64 offset, int length,
#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
ret = ::pread (fileId, buffer, length, offset);
+#elif defined(_WIN32)
+ HANDLE hFile = (HANDLE)_get_osfhandle(fileId);
+ OVERLAPPED overlapped = {0};
+ LARGE_INTEGER pos;
+
+ pos.QuadPart = offset;
+ overlapped.Offset = pos.LowPart;
+ overlapped.OffsetHigh = pos.HighPart;
+
+ if (!ReadFile(hFile, buffer, length, (DWORD *) &ret, &overlapped))
+ ret = -1;
#else
Sync sync (&syncObject, "IO::pread");
sync.lock (Exclusive);
@@ -560,6 +571,20 @@ int IO::pwrite(int64 offset, int length,
#if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
ret = ::pwrite (fileId, buffer, length, offset);
+#elif defined(_WIN32)
+
+ ASSERT(length > 0);
+
+ HANDLE hFile = (HANDLE)_get_osfhandle(fileId);
+ OVERLAPPED overlapped = {0};
+ LARGE_INTEGER pos;
+
+ pos.QuadPart = offset;
+ overlapped.Offset = pos.LowPart;
+ overlapped.OffsetHigh = pos.HighPart;
+
+ if (!WriteFile(hFile, buffer, length, (DWORD *)&ret, &overlapped))
+ ret = -1;
#else
Sync sync (&syncObject, "IO::pwrite");
sync.lock (Exclusive);
=== modified file 'storage/falcon/SerialLogFile.cpp'
--- a/storage/falcon/SerialLogFile.cpp 2008-06-23 10:22:43 +0000
+++ b/storage/falcon/SerialLogFile.cpp 2008-07-08 21:36:34 +0000
@@ -179,22 +179,15 @@ void SerialLogFile::write(int64 position
priority.schedule(PRIORITY_HIGH);
#ifdef _WIN32
-
- Sync sync(&syncObject, "SerialLogFile::write");
- sync.lock(Exclusive);
-
- if (position != offset)
- {
- LARGE_INTEGER pos;
- pos.QuadPart = position;
-
- if (!SetFilePointerEx(handle, pos, NULL, FILE_BEGIN))
- throw SQLError(IO_ERROR, "serial log SetFilePointerEx failed with %d", GetLastError());
- }
+ LARGE_INTEGER pos;
+ pos.QuadPart = position;
+ OVERLAPPED overlapped = {0};
+ overlapped.Offset = pos.LowPart;
+ overlapped.OffsetHigh = pos.HighPart;
DWORD ret;
- if (!WriteFile(handle, data, effectiveLength, &ret, NULL))
+ if (!WriteFile(handle, data, effectiveLength, &ret, &overlapped))
{
int lastError = GetLastError();
@@ -259,18 +252,17 @@ uint32 SerialLogFile::read(int64 positio
priority.schedule(PRIORITY_HIGH);
#ifdef _WIN32
- Sync sync(&syncObject, "SerialLogFile::read");
- sync.lock(Exclusive);
+
ASSERT(position < writePoint || writePoint == 0);
LARGE_INTEGER pos;
pos.QuadPart = position;
-
- if (!SetFilePointerEx(handle, pos, NULL, FILE_BEGIN))
- throw SQLError(IO_ERROR, "serial log SetFilePointer failed with %d", GetLastError());
+ OVERLAPPED overlapped = {0};
+ overlapped.Offset = pos.LowPart;
+ overlapped.OffsetHigh = pos.HighPart;
DWORD ret;
- if (!ReadFile(handle, data, effectiveLength, &ret, NULL))
+ if (!ReadFile(handle, data, effectiveLength, &ret, &overlapped))
throw SQLError(IO_ERROR, "serial log ReadFile failed with %d", GetLastError());
offset = position + effectiveLength;
| Thread |
|---|
| • bzr push into mysql-6.0-falcon branch (vvaintroub:2734 to 2735) WL#3998 | Vladislav Vaintroub | 8 Jul |