forked from premiere/premiere-libtorrent
merged ERROR_CANT_WAIT patch from RC_0_16
This commit is contained in:
parent
66a9f31ebf
commit
71653be7f0
|
@ -9,6 +9,7 @@
|
||||||
* fix uTP edge case where udp socket buffer fills up
|
* fix uTP edge case where udp socket buffer fills up
|
||||||
* fix nagle implementation in uTP
|
* fix nagle implementation in uTP
|
||||||
|
|
||||||
|
* attempt to handle ERROR_CANT_WAIT disk error on windows
|
||||||
* improve peers exchanged over PEX
|
* improve peers exchanged over PEX
|
||||||
* fixed rare crash in ut_metadata extension
|
* fixed rare crash in ut_metadata extension
|
||||||
* fixed files checking issue
|
* fixed files checking issue
|
||||||
|
|
33
src/file.cpp
33
src/file.cpp
|
@ -1324,24 +1324,32 @@ namespace libtorrent
|
||||||
ol.OffsetHigh = DWORD(file_offset >> 32);
|
ol.OffsetHigh = DWORD(file_offset >> 32);
|
||||||
ol.Offset = DWORD(file_offset & 0xffffffff);
|
ol.Offset = DWORD(file_offset & 0xffffffff);
|
||||||
ol.hEvent = CreateEvent(0, true, false, 0);
|
ol.hEvent = CreateEvent(0, true, false, 0);
|
||||||
|
if (ol.hEvent == ERROR_INVALID_HANDLE)
|
||||||
|
{
|
||||||
|
ec.assign(last_error, get_system_category());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ret += size;
|
ret += size;
|
||||||
size = num_pages * m_page_size;
|
size = num_pages * m_page_size;
|
||||||
if (ReadFileScatter(m_file_handle, segment_array, size, 0, &ol) == 0)
|
if (ReadFileScatter(m_file_handle, segment_array, size, 0, &ol) == 0)
|
||||||
{
|
{
|
||||||
DWORD last_error = GetLastError();
|
DWORD last_error = GetLastError();
|
||||||
if (last_error != ERROR_IO_PENDING)
|
if (last_error != ERROR_IO_PENDING
|
||||||
|
&& last_error != ERROR_CANT_WAIT)
|
||||||
{
|
{
|
||||||
ec.assign(GetLastError(), get_system_category());
|
ec.assign(last_error, get_system_category());
|
||||||
CloseHandle(ol.hEvent);
|
CloseHandle(ol.hEvent);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
DWORD num_read;
|
DWORD num_read;
|
||||||
if (GetOverlappedResult(m_file_handle, &ol, &num_read, true) == 0)
|
if (GetOverlappedResult(m_file_handle, &ol, &num_read, true) == 0)
|
||||||
{
|
{
|
||||||
if (GetLastError() != ERROR_HANDLE_EOF)
|
DWORD last_error = GetLastError();
|
||||||
|
if (last_error != ERROR_HANDLE_EOF)
|
||||||
{
|
{
|
||||||
ec.assign(GetLastError(), get_system_category());
|
TORRENT_ASSERT(last_error != ERROR_CANT_WAIT);
|
||||||
|
ec.assign(last_error, get_system_category());
|
||||||
CloseHandle(ol.hEvent);
|
CloseHandle(ol.hEvent);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1539,6 +1547,11 @@ namespace libtorrent
|
||||||
ol.OffsetHigh = DWORD(file_offset >> 32);
|
ol.OffsetHigh = DWORD(file_offset >> 32);
|
||||||
ol.Offset = DWORD(file_offset & 0xffffffff);
|
ol.Offset = DWORD(file_offset & 0xffffffff);
|
||||||
ol.hEvent = CreateEvent(0, true, false, 0);
|
ol.hEvent = CreateEvent(0, true, false, 0);
|
||||||
|
if (ol.hEvent == ERROR_INVALID_HANDLE)
|
||||||
|
{
|
||||||
|
ec.assign(last_error, get_system_category());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ret += size;
|
ret += size;
|
||||||
size_type file_size = 0;
|
size_type file_size = 0;
|
||||||
|
@ -1554,17 +1567,21 @@ namespace libtorrent
|
||||||
|
|
||||||
if (WriteFileGather(m_file_handle, segment_array, size, 0, &ol) == 0)
|
if (WriteFileGather(m_file_handle, segment_array, size, 0, &ol) == 0)
|
||||||
{
|
{
|
||||||
if (GetLastError() != ERROR_IO_PENDING)
|
DWORD last_error = GetLastError();
|
||||||
|
if (last_error != ERROR_IO_PENDING
|
||||||
|
&& last_error != ERROR_CANT_WAIT)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(GetLastError() != ERROR_BAD_ARGUMENTS);
|
TORRENT_ASSERT(last_error != ERROR_BAD_ARGUMENTS);
|
||||||
ec.assign(GetLastError(), get_system_category());
|
ec.assign(last_error, get_system_category());
|
||||||
CloseHandle(ol.hEvent);
|
CloseHandle(ol.hEvent);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
DWORD num_written;
|
DWORD num_written;
|
||||||
if (GetOverlappedResult(m_file_handle, &ol, &num_written, true) == 0)
|
if (GetOverlappedResult(m_file_handle, &ol, &num_written, true) == 0)
|
||||||
{
|
{
|
||||||
ec.assign(GetLastError(), get_system_category());
|
DWORD last_error = GetLastError();
|
||||||
|
TORRENT_ASSERT(last_error != ERROR_CANT_WAIT);
|
||||||
|
ec.assign(last_error, get_system_category());
|
||||||
CloseHandle(ol.hEvent);
|
CloseHandle(ol.hEvent);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue