Commit 012e724d authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-27796 Windows - starting server with huge innodb-log-buffer-size may fail

Fixed tpool::pread() and tpool::pwrite() to return SSIZE_T on Windows,
so that huge numbers are not converted to negatives.

Also, make sure to never attempt reading/writing more bytes than
DWORD can accomodate (4G)
parent 9e39d0ae
......@@ -72,7 +72,7 @@ struct WinIoInit
static WinIoInit win_io_init;
int pread(const native_file_handle &h, void *buf, size_t count,
SSIZE_T pread(const native_file_handle &h, void *buf, size_t count,
unsigned long long offset)
{
OVERLAPPED ov{};
......@@ -81,6 +81,8 @@ int pread(const native_file_handle &h, void *buf, size_t count,
ov.Offset= uli.LowPart;
ov.OffsetHigh= uli.HighPart;
ov.hEvent= win_get_syncio_event();
if (count > 0xFFFFFFFF)
count= 0xFFFFFFFF;
if (ReadFile(h, buf, (DWORD) count, 0, &ov) ||
(GetLastError() == ERROR_IO_PENDING))
......@@ -93,7 +95,7 @@ int pread(const native_file_handle &h, void *buf, size_t count,
return -1;
}
int pwrite(const native_file_handle &h, void *buf, size_t count,
SSIZE_T pwrite(const native_file_handle &h, void *buf, size_t count,
unsigned long long offset)
{
OVERLAPPED ov{};
......@@ -102,7 +104,8 @@ int pwrite(const native_file_handle &h, void *buf, size_t count,
ov.Offset= uli.LowPart;
ov.OffsetHigh= uli.HighPart;
ov.hEvent= win_get_syncio_event();
if (count > 0xFFFFFFFF)
count= 0xFFFFFFFF;
if (WriteFile(h, buf, (DWORD) count, 0, &ov) ||
(GetLastError() == ERROR_IO_PENDING))
{
......
......@@ -252,9 +252,9 @@ create_thread_pool_win(int min_threads= DEFAULT_MIN_POOL_THREADS,
opened with FILE_FLAG_OVERLAPPED, and bound to completion
port.
*/
int pwrite(const native_file_handle &h, void *buf, size_t count,
SSIZE_T pwrite(const native_file_handle &h, void *buf, size_t count,
unsigned long long offset);
int pread(const native_file_handle &h, void *buf, size_t count,
SSIZE_T pread(const native_file_handle &h, void *buf, size_t count,
unsigned long long offset);
HANDLE win_get_syncio_event();
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment