From 839b9b781de4ea1bf87a49e72330334aec53893b Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 20 Dec 2018 15:14:28 +0200 Subject: [PATCH] MXS-2219 Differentiate between READY and ERROR with http::Async An async http operation that has not been initiated is READY, while an operation that cannot be initated is ERRORed. --- maxutils/maxbase/src/http.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/maxutils/maxbase/src/http.cc b/maxutils/maxbase/src/http.cc index 9ca6d0496..d9318d565 100644 --- a/maxutils/maxbase/src/http.cc +++ b/maxutils/maxbase/src/http.cc @@ -172,21 +172,22 @@ struct Context Errbuf * pErrbuf; }; -class ErrorImp : public Async::Imp +class ReadyImp : public Async::Imp { public: - ErrorImp() + ReadyImp(Async::status_t status = Async::READY) + : m_status(status) { } Async::status_t status() const { - return Async::ERROR; + return m_status; } Async::status_t perform(long timeout_ms) { - return Async::ERROR; + return m_status; } long wait_no_more_than() const @@ -200,7 +201,8 @@ public: } private: - vector m_results; + Async::status_t m_status; + vector m_results; }; class HttpImp : public Async::Imp @@ -485,7 +487,7 @@ Async::Imp::~Imp() } Async::Async() - : m_sImp(std::make_shared()) + : m_sImp(std::make_shared()) { } @@ -507,7 +509,7 @@ Async get_async(const std::vector& urls, } else { - sImp = std::make_shared(); + sImp = std::make_shared(Async::ERROR); } return Async(sImp);