You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2020/04/24 22:09:46 UTC
[mesos] 01/06: Fixed discard race in libwinio io operations.
This is an automated email from the ASF dual-hosted git repository.
bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 413981ad87da7c4f5f312e52a1f24f11cfe87fbd
Author: Benjamin Mahler <bm...@apache.org>
AuthorDate: Tue Apr 21 12:56:38 2020 -0400
Fixed discard race in libwinio io operations.
When getting a discard request for an io operation on windows,
a cancellation is requested and when the io operation completes
a check is performed to see if the future had a discard requested.
However, it's possible that the operation completed successfully
or had a failure and we should not be dropping that information
from the caller.
To correctly check whether the cancellation succeded, we need
to check for ERROR_OPERATION_ABORTED.
Review: https://reviews.apache.org/r/72404
---
3rdparty/libprocess/src/windows/libwinio.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/3rdparty/libprocess/src/windows/libwinio.cpp b/3rdparty/libprocess/src/windows/libwinio.cpp
index 85ee7ea..453b9df 100644
--- a/3rdparty/libprocess/src/windows/libwinio.cpp
+++ b/3rdparty/libprocess/src/windows/libwinio.cpp
@@ -141,7 +141,11 @@ static_assert(
template <typename T>
static void set_io_promise(Promise<T>* promise, const T& data, DWORD error)
{
- if (promise->future().hasDiscard()) {
+ // If our discard induced CancelIoEx call succeeded, then we
+ // will see ERROR_OPERATION_ABORTED. Otherwise, the discard
+ // lost the race against the operation completing and we
+ // should just surface the result.
+ if (promise->future().hasDiscard() && error == ERROR_OPERATION_ABORTED) {
promise->discard();
} else if (error == ERROR_SUCCESS) {
promise->set(data);