diff options
author | Spencer Jackson <spencer.jackson@mongodb.com> | 2018-08-28 11:24:58 -0400 |
---|---|---|
committer | Spencer Jackson <spencer.jackson@mongodb.com> | 2018-09-18 13:22:50 -0400 |
commit | 67ab3ae97432353dea52c74fcc5982ea4d4d7ae6 (patch) | |
tree | dc4d545a474eb98e5d82d5c4711a7e055216f265 /src/third_party/asio-master/asio/include/asio | |
parent | e65ff57e108ed69c46cc0b0ccbdd675663de2469 (diff) | |
download | mongo-67ab3ae97432353dea52c74fcc5982ea4d4d7ae6.tar.gz |
SERVER-36885: Make ASIO remember IOCP state when out of resources
Diffstat (limited to 'src/third_party/asio-master/asio/include/asio')
-rw-r--r-- | src/third_party/asio-master/asio/include/asio/detail/impl/win_iocp_io_context.ipp | 15 | ||||
-rw-r--r-- | src/third_party/asio-master/asio/include/asio/detail/win_iocp_operation.hpp | 9 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/third_party/asio-master/asio/include/asio/detail/impl/win_iocp_io_context.ipp b/src/third_party/asio-master/asio/include/asio/detail/impl/win_iocp_io_context.ipp index c371b86b250..ebb4b62b179 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/impl/win_iocp_io_context.ipp +++ b/src/third_party/asio-master/asio/include/asio/detail/impl/win_iocp_io_context.ipp @@ -252,7 +252,7 @@ void win_iocp_io_context::post_deferred_completion(win_iocp_operation* op) op->ready_ = 1; // Enqueue the operation on the I/O completion port. - if (!::PostQueuedCompletionStatus(iocp_.handle, 0, 0, op)) + if (!::PostQueuedCompletionStatus(iocp_.handle, 0, op->completionKey(), op)) { // Out of resources. Put on completed queue instead. mutex::scoped_lock lock(dispatch_mutex_); @@ -272,7 +272,7 @@ void win_iocp_io_context::post_deferred_completions( op->ready_ = 1; // Enqueue the operation on the I/O completion port. - if (!::PostQueuedCompletionStatus(iocp_.handle, 0, 0, op)) + if (!::PostQueuedCompletionStatus(iocp_.handle, 0, op->completionKey(), op)) { // Out of resources. Put on completed queue instead. mutex::scoped_lock lock(dispatch_mutex_); @@ -298,9 +298,10 @@ void win_iocp_io_context::on_pending(win_iocp_operation* op) { if (::InterlockedCompareExchange(&op->ready_, 1, 0) == 1) { + op->completionKey() = overlapped_contains_result; // Enqueue the operation on the I/O completion port. if (!::PostQueuedCompletionStatus(iocp_.handle, - 0, overlapped_contains_result, op)) + 0, op->completionKey(), op)) { // Out of resources. Put on completed queue instead. mutex::scoped_lock lock(dispatch_mutex_); @@ -322,9 +323,11 @@ void win_iocp_io_context::on_completion(win_iocp_operation* op, op->Offset = last_error; op->OffsetHigh = bytes_transferred; + // Enqueue the operation on the I/O completion port. + op->completionKey() = overlapped_contains_result; if (!::PostQueuedCompletionStatus(iocp_.handle, - 0, overlapped_contains_result, op)) + 0, op->completionKey(), op)) { // Out of resources. Put on completed queue instead. mutex::scoped_lock lock(dispatch_mutex_); @@ -344,9 +347,11 @@ void win_iocp_io_context::on_completion(win_iocp_operation* op, op->Offset = ec.value(); op->OffsetHigh = bytes_transferred; + // Enqueue the operation on the I/O completion port. + op->completionKey() = overlapped_contains_result; if (!::PostQueuedCompletionStatus(iocp_.handle, - 0, overlapped_contains_result, op)) + 0, op->completionKey(), op)) { // Out of resources. Put on completed queue instead. mutex::scoped_lock lock(dispatch_mutex_); diff --git a/src/third_party/asio-master/asio/include/asio/detail/win_iocp_operation.hpp b/src/third_party/asio-master/asio/include/asio/detail/win_iocp_operation.hpp index 81d43f07f64..e0cbcc56ced 100644 --- a/src/third_party/asio-master/asio/include/asio/detail/win_iocp_operation.hpp +++ b/src/third_party/asio-master/asio/include/asio/detail/win_iocp_operation.hpp @@ -51,6 +51,10 @@ public: func_(0, this, asio::error_code(), 0); } + ULONG_PTR& completionKey() { + return completionKey_; + } + protected: typedef void (*func_type)( void*, win_iocp_operation*, @@ -58,7 +62,8 @@ protected: win_iocp_operation(func_type func) : next_(0), - func_(func) + func_(func), + completionKey_(0) { reset(); } @@ -76,6 +81,7 @@ protected: OffsetHigh = 0; hEvent = 0; ready_ = 0; + completionKey_ = 0; } private: @@ -84,6 +90,7 @@ private: win_iocp_operation* next_; func_type func_; long ready_; + ULONG_PTR completionKey_; }; } // namespace detail |