merge file close fix from RC_0_16

This commit is contained in:
Arvid Norberg 2013-04-10 23:37:22 +00:00
parent 520b8bfcd1
commit 3d19ea4b18
2 changed files with 8 additions and 6 deletions

View File

@ -20,6 +20,7 @@
* fix uTP edge case where udp socket buffer fills up
* 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
* 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())

View File

@ -857,7 +857,8 @@ namespace libtorrent
}
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());
return -1;
@ -999,10 +1000,10 @@ namespace libtorrent
DWORD temp;
bool use_overlapped = m_open_mode & no_buffer;
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);
error_code error;
if (use_overlapped)
if (use_overlapped && ret == FALSE && GetLastError() == ERROR_IO_PENDING)
ol.wait(m_file_handle, error);
}
#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)
, out, sizeof(out), &returned_bytes, overlapped ? &ol.ol : NULL);
if (overlapped)
if (overlapped && ret == FALSE && GetLastError() == ERROR_IO_PENDING)
{
error_code ec;
returned_bytes = ol.wait(file, ec);
@ -1276,10 +1277,10 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
DWORD temp;
FILE_SET_SPARSE_BUFFER b;
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);
error_code ec;
if (use_overlapped)
if (use_overlapped && ret == FALSE && GetLastError() == ERROR_IO_PENDING)
{
ol.wait(m_file_handle, ec);
}