From: Sangwan Kwon Date: Tue, 31 Dec 2019 07:22:52 +0000 (+0900) Subject: Remove timeout feature on docker-rmi X-Git-Tag: submit/tizen/20200810.073515~118 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ff0d71114d3721e61deb111f25a417864a50b516;p=platform%2Fcore%2Fsecurity%2Fvist.git Remove timeout feature on docker-rmi Since docker does not support systemd, there is no need to exist timeout feature. Signed-off-by: Sangwan Kwon --- diff --git a/src/vist/rmi/gateway.cpp b/src/vist/rmi/gateway.cpp index a7f6ab4..e9fbdb8 100644 --- a/src/vist/rmi/gateway.cpp +++ b/src/vist/rmi/gateway.cpp @@ -51,9 +51,9 @@ public: this->server = std::make_unique(path, dispatcher); } - inline void start(unsigned int timeout, Timer::Predicate condition) + inline void start() { - this->server->run(timeout, condition); + this->server->run(); } inline void stop() @@ -71,9 +71,9 @@ Gateway::Gateway(const std::string& path) : pImpl(std::make_unique(*this, Gateway::~Gateway() = default; -void Gateway::start(unsigned int timeout, Timer::Predicate condition) +void Gateway::start() { - this->pImpl->start(timeout, condition); + this->pImpl->start(); } void Gateway::stop(void) diff --git a/src/vist/rmi/gateway.hpp b/src/vist/rmi/gateway.hpp index 0b8ff8c..79dad24 100644 --- a/src/vist/rmi/gateway.hpp +++ b/src/vist/rmi/gateway.hpp @@ -19,7 +19,6 @@ #define EXPOSE(gateway, object, function) gateway.expose(object, #function, function) #include -#include #include #include @@ -38,8 +37,8 @@ public: Gateway(Gateway&&) = default; Gateway& operator=(Gateway&&) = default; - void start(unsigned int timeout = 0, Timer::Predicate condition = nullptr); - void stop(void); + void start(); + void stop(); template void expose(O& object, const std::string& name, F&& func); diff --git a/src/vist/rmi/impl/protocol.cpp b/src/vist/rmi/impl/protocol.cpp index 82c49b0..70e1cb4 100644 --- a/src/vist/rmi/impl/protocol.cpp +++ b/src/vist/rmi/impl/protocol.cpp @@ -64,13 +64,12 @@ Message Protocol::Request(Socket& socket, Message& message) return Protocol::Recv(socket); } -void Protocol::Async::dispatch(const Task& task, std::atomic& polling) +void Protocol::Async::dispatch(const Task& task) { - polling = true; auto self = shared_from_this(); const auto& header = boost::asio::buffer(&this->message.header, sizeof(Message::Header)); - auto handler = [self, task, &polling](const auto& error, std::size_t size) { + auto handler = [self, task](const auto& error, std::size_t size) { if (error) { if (error == boost::asio::error::eof) { DEBUG(VIST) << "Socket EoF event occured."; @@ -93,13 +92,13 @@ void Protocol::Async::dispatch(const Task& task, std::atomic& polling) << readen << ", " << self->message.size(); self->message.disclose(self->message.signature); - self->process(task, polling); + self->process(task); }; boost::asio::async_read(self->socket, header, handler); } -void Protocol::Async::process(const Task& task, std::atomic& polling) +void Protocol::Async::process(const Task& task) { bool raised = false; std::string errMsg; @@ -125,7 +124,7 @@ void Protocol::Async::process(const Task& task, std::atomic& polling) auto self = shared_from_this(); const auto& headerBuffer = boost::asio::buffer(&this->message.header, sizeof(Message::Header)); - auto handler = [self, task, &polling](const auto& error, std::size_t size) { + auto handler = [self, task](const auto& error, std::size_t size) { if (error || size != sizeof(Message::Header)) THROW(ErrCode::ProtocolBroken) << "Failed to send message header: " << error.message(); @@ -136,7 +135,7 @@ void Protocol::Async::process(const Task& task, std::atomic& polling) THROW(ErrCode::ProtocolBroken) << "Failed to send message content."; /// Re-dispatch for next request. - self->dispatch(task, polling); + self->dispatch(task); }; boost::asio::async_write(self->socket, headerBuffer, handler); diff --git a/src/vist/rmi/impl/protocol.hpp b/src/vist/rmi/impl/protocol.hpp index aa7ecf6..eff3505 100644 --- a/src/vist/rmi/impl/protocol.hpp +++ b/src/vist/rmi/impl/protocol.hpp @@ -18,7 +18,6 @@ #include -#include #include #include @@ -44,8 +43,8 @@ struct Protocol { class Async : public std::enable_shared_from_this { public: explicit Async(Context& context) : socket(context) {} - void dispatch(const Task& task, std::atomic& polling); - void process(const Task& task, std::atomic& polling); + void dispatch(const Task& task); + void process(const Task& task); inline Socket& getSocket() { diff --git a/src/vist/rmi/impl/server.hpp b/src/vist/rmi/impl/server.hpp index 5e59b09..098e69d 100644 --- a/src/vist/rmi/impl/server.hpp +++ b/src/vist/rmi/impl/server.hpp @@ -18,11 +18,9 @@ #include "protocol.hpp" -#include #include #include -#include #include #include #include @@ -36,7 +34,7 @@ namespace impl { class Server { public: - Server(const std::string& path, const Protocol::Task& task) : polling(false) + Server(const std::string& path, const Protocol::Task& task) { errno = 0; if (::unlink(path.c_str()) == -1 && errno != ENOENT) @@ -56,31 +54,15 @@ public: if (error) THROW(ErrCode::RuntimeError) << error.message(); - asyncSession->dispatch(task, this->polling); + asyncSession->dispatch(task); this->accept(task); }; this->acceptor->async_accept(asyncSession->getSocket(), handler); } - inline void run(unsigned int timeout = 0, Timer::Predicate condition = nullptr) + inline void run() { - if (timeout > 0) { - auto stopper = [this]() { - INFO(VIST) << "There are no sessions. And timeout is occured."; - this->context.stop(); - }; - - auto wrapper = [this, condition]() -> bool { - if (condition) - return condition() && polling == false; - - return polling == false; - }; - - Timer::ExecOnce(stopper, wrapper, timeout); - } - this->context.run(); } @@ -92,9 +74,6 @@ public: private: Protocol::Context context; std::unique_ptr acceptor; - - /// check for session is maintained - std::atomic polling; }; } // namespace impl diff --git a/src/vist/rmi/impl/tests/protocol.cpp b/src/vist/rmi/impl/tests/protocol.cpp index 2b2e4ac..5e03689 100644 --- a/src/vist/rmi/impl/tests/protocol.cpp +++ b/src/vist/rmi/impl/tests/protocol.cpp @@ -105,7 +105,6 @@ TEST(ProtocolTests, sync_server_sync_client) serverThread.join(); } -/* example without polling memeber variable TEST(ProtocolTests, async_server_sync_client) { std::string sockPath = "vist-test.sock"; @@ -172,4 +171,3 @@ TEST(ProtocolTests, async_server_sync_client) if (serverThread.joinable()) serverThread.join(); } -*/