Remove timeout feature on docker-rmi
authorSangwan Kwon <sangwan.kwon@samsung.com>
Tue, 31 Dec 2019 07:22:52 +0000 (16:22 +0900)
committer권상완/Security 2Lab(SR)/Engineer/삼성전자 <sangwan.kwon@samsung.com>
Fri, 3 Jan 2020 07:58:41 +0000 (16:58 +0900)
Since docker does not support systemd, there is no need to exist
timeout feature.

Signed-off-by: Sangwan Kwon <sangwan.kwon@samsung.com>
src/vist/rmi/gateway.cpp
src/vist/rmi/gateway.hpp
src/vist/rmi/impl/protocol.cpp
src/vist/rmi/impl/protocol.hpp
src/vist/rmi/impl/server.hpp
src/vist/rmi/impl/tests/protocol.cpp

index a7f6ab4..e9fbdb8 100644 (file)
@@ -51,9 +51,9 @@ public:
                this->server = std::make_unique<Server>(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<Impl>(*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)
index 0b8ff8c..79dad24 100644 (file)
@@ -19,7 +19,6 @@
 #define EXPOSE(gateway, object, function) gateway.expose(object, #function, function)
 
 #include <vist/klass/functor.hpp>
-#include <vist/timer.hpp>
 
 #include <memory>
 #include <string>
@@ -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<typename O, typename F>
        void expose(O& object, const std::string& name, F&& func);
index 82c49b0..70e1cb4 100644 (file)
@@ -64,13 +64,12 @@ Message Protocol::Request(Socket& socket, Message& message)
        return Protocol::Recv(socket);
 }
 
-void Protocol::Async::dispatch(const Task& task, std::atomic<bool>& 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<bool>& 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<bool>& 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<bool>& 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<bool>& 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);
index aa7ecf6..eff3505 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <vist/rmi/message.hpp>
 
-#include <atomic>
 #include <functional>
 
 #include <boost/asio.hpp>
@@ -44,8 +43,8 @@ struct Protocol {
        class Async : public std::enable_shared_from_this<Async> {
        public:
                explicit Async(Context& context) : socket(context) {}
-               void dispatch(const Task& task, std::atomic<bool>& polling);
-               void process(const Task& task, std::atomic<bool>& polling);
+               void dispatch(const Task& task);
+               void process(const Task& task);
 
                inline Socket& getSocket()
                {
index 5e59b09..098e69d 100644 (file)
 
 #include "protocol.hpp"
 
-#include <vist/timer.hpp>
 #include <vist/exception.hpp>
 #include <vist/logger.hpp>
 
-#include <atomic>
 #include <chrono>
 #include <memory>
 #include <thread>
@@ -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<Protocol::Acceptor> acceptor;
-
-       /// check for session is maintained
-       std::atomic<bool> polling;
 };
 
 } // namespace impl
index 2b2e4ac..5e03689 100644 (file)
@@ -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();
 }
-*/