merge file close fix from RC_0_16
This commit is contained in:
parent
520b8bfcd1
commit
3d19ea4b18
|
@ -20,6 +20,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
|
||||||
|
|
||||||
|
* fix hanging issue when closing files on windows (completing a download)
|
||||||
* fix piece picking edge case that could cause torrents to get stuck at hash failure
|
* fix piece picking edge case that could cause torrents to get stuck at hash failure
|
||||||
* try unencrypted connections first, and fall back to encryption if it fails (performance improvement)
|
* try unencrypted connections first, and fall back to encryption if it fails (performance improvement)
|
||||||
* add missing functions to python binding (flush_cache(), remap_files() and orig_files())
|
* add missing functions to python binding (flush_cache(), remap_files() and orig_files())
|
||||||
|
|
13
src/file.cpp
13
src/file.cpp
|
@ -857,7 +857,8 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
int wait(HANDLE file, error_code& ec)
|
int wait(HANDLE file, error_code& ec)
|
||||||
{
|
{
|
||||||
if (WaitForSingleObject(ol.hEvent, INFINITE) == WAIT_FAILED)
|
if (ol.hEvent != INVALID_HANDLE_VALUE
|
||||||
|
&& WaitForSingleObject(ol.hEvent, INFINITE) == WAIT_FAILED)
|
||||||
{
|
{
|
||||||
ec.assign(GetLastError(), get_system_category());
|
ec.assign(GetLastError(), get_system_category());
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -999,10 +1000,10 @@ namespace libtorrent
|
||||||
DWORD temp;
|
DWORD temp;
|
||||||
bool use_overlapped = m_open_mode & no_buffer;
|
bool use_overlapped = m_open_mode & no_buffer;
|
||||||
overlapped_t ol;
|
overlapped_t ol;
|
||||||
::DeviceIoControl(m_file_handle, FSCTL_SET_SPARSE, 0, 0
|
BOOL ret = ::DeviceIoControl(m_file_handle, FSCTL_SET_SPARSE, 0, 0
|
||||||
, 0, 0, &temp, use_overlapped ? &ol.ol : NULL);
|
, 0, 0, &temp, use_overlapped ? &ol.ol : NULL);
|
||||||
error_code error;
|
error_code error;
|
||||||
if (use_overlapped)
|
if (use_overlapped && ret == FALSE && GetLastError() == ERROR_IO_PENDING)
|
||||||
ol.wait(m_file_handle, error);
|
ol.wait(m_file_handle, error);
|
||||||
}
|
}
|
||||||
#else // TORRENT_WINDOWS
|
#else // TORRENT_WINDOWS
|
||||||
|
@ -1230,7 +1231,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
||||||
BOOL ret = DeviceIoControl(file, FSCTL_QUERY_ALLOCATED_RANGES, (void*)&in, sizeof(in)
|
BOOL ret = DeviceIoControl(file, FSCTL_QUERY_ALLOCATED_RANGES, (void*)&in, sizeof(in)
|
||||||
, out, sizeof(out), &returned_bytes, overlapped ? &ol.ol : NULL);
|
, out, sizeof(out), &returned_bytes, overlapped ? &ol.ol : NULL);
|
||||||
|
|
||||||
if (overlapped)
|
if (overlapped && ret == FALSE && GetLastError() == ERROR_IO_PENDING)
|
||||||
{
|
{
|
||||||
error_code ec;
|
error_code ec;
|
||||||
returned_bytes = ol.wait(file, ec);
|
returned_bytes = ol.wait(file, ec);
|
||||||
|
@ -1276,10 +1277,10 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
||||||
DWORD temp;
|
DWORD temp;
|
||||||
FILE_SET_SPARSE_BUFFER b;
|
FILE_SET_SPARSE_BUFFER b;
|
||||||
b.SetSparse = FALSE;
|
b.SetSparse = FALSE;
|
||||||
int ret = ::DeviceIoControl(m_file_handle, FSCTL_SET_SPARSE, &b, sizeof(b)
|
BOOL ret = ::DeviceIoControl(m_file_handle, FSCTL_SET_SPARSE, &b, sizeof(b)
|
||||||
, 0, 0, &temp, use_overlapped ? &ol.ol : NULL);
|
, 0, 0, &temp, use_overlapped ? &ol.ol : NULL);
|
||||||
error_code ec;
|
error_code ec;
|
||||||
if (use_overlapped)
|
if (use_overlapped && ret == FALSE && GetLastError() == ERROR_IO_PENDING)
|
||||||
{
|
{
|
||||||
ol.wait(m_file_handle, ec);
|
ol.wait(m_file_handle, ec);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue