From 5133fec4cad4e2bb73e31eff2d836c2a75cd3527 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 13 Feb 2013 18:03:59 +0000 Subject: [PATCH] merged file error handling from RC_0_16 --- src/file.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index ebcc16e1e..2b5670cdc 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1344,7 +1344,12 @@ namespace libtorrent CloseHandle(ol.hEvent); return -1; } - WaitForSingleObject(ol.hEvent, INFINITE); + if (WaitForSingleObject(ol.hEvent, INFINITE) == WAIT_FAILED) + { + ec.assign(GetLastError(), get_system_category()); + CloseHandle(ol.hEvent); + return -1; + } DWORD num_read; if (GetOverlappedResult(m_file_handle, &ol, &num_read, false) == 0) { @@ -1584,7 +1589,12 @@ namespace libtorrent CloseHandle(ol.hEvent); return -1; } - WaitForSingleObject(ol.hEvent, INFINITE); + if (WaitForSingleObject(ol.hEvent, INFINITE) == WAIT_FAILED) + { + ec.assign(GetLastError(), get_system_category()); + CloseHandle(ol.hEvent); + return -1; + } DWORD num_written; if (GetOverlappedResult(m_file_handle, &ol, &num_written, false) == 0) {