From 7acf1c0827956af47d7211a0a6ee1d54ee10b37a Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 6 Nov 2017 14:56:12 -0800 Subject: [PATCH] rgw: don't allow for io_id to complete more than once Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_coroutine.cc | 7 ++++++- src/rgw/rgw_coroutine.h | 1 + src/rgw/rgw_http_client.h | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_coroutine.cc b/src/rgw/rgw_coroutine.cc index cbdeecd84cdd2..4e3fed07d8d4e 100644 --- a/src/rgw/rgw_coroutine.cc +++ b/src/rgw/rgw_coroutine.cc @@ -62,7 +62,10 @@ void RGWCompletionManager::_complete(RGWAioCompletionNotifier *cn, const rgw_io_ cns.erase(cn); } -#warning shouldn't have more than one entry in complete_reqs per io_id + if (complete_reqs_set.find(io_id) != complete_reqs_set.end()) { + /* already have completion for this io_id, don't allow multiple completions for it */ + return; + } complete_reqs.push_back(io_completion{io_id, user_info}); cond.Signal(); } @@ -77,6 +80,7 @@ int RGWCompletionManager::get_next(io_completion *io) cond.Wait(lock); } *io = complete_reqs.front(); + complete_reqs_set.erase(io->io_id); complete_reqs.pop_front(); return 0; } @@ -88,6 +92,7 @@ bool RGWCompletionManager::try_get_next(io_completion *io) return false; } *io = complete_reqs.front(); + complete_reqs_set.erase(io->io_id); complete_reqs.pop_front(); return true; } diff --git a/src/rgw/rgw_coroutine.h b/src/rgw/rgw_coroutine.h index a7b2797264c9c..d61b40aae9ba5 100644 --- a/src/rgw/rgw_coroutine.h +++ b/src/rgw/rgw_coroutine.h @@ -43,6 +43,7 @@ class RGWCompletionManager : public RefCountedObject { void *user_info; }; list complete_reqs; + set complete_reqs_set; using NotifierRef = boost::intrusive_ptr; set cns; diff --git a/src/rgw/rgw_http_client.h b/src/rgw/rgw_http_client.h index 9c64feb19aa73..127e9e81ad1e3 100644 --- a/src/rgw/rgw_http_client.h +++ b/src/rgw/rgw_http_client.h @@ -41,6 +41,14 @@ struct rgw_io_id { bool intersects(const rgw_io_id& rhs) { return (id == rhs.id && ((channels | rhs.channels) != 0)); } + + bool operator<(const rgw_io_id& rhs) const { + if (id < rhs.id) { + return true; + } + return (id == rhs.id && + channels < rhs.channels); + } }; class RGWIOProvider -- 2.39.5