Dispatching in the main thread
[platform/core/security/vasum.git] / server / server.hpp
index ba2334e..a688653 100644 (file)
 #ifndef SERVER_SERVER_HPP
 #define SERVER_SERVER_HPP
 
+#include "zones-manager.hpp"
+
 #include "utils/latch.hpp"
+#include "utils/signalfd.hpp"
+#include "utils/glib-loop.hpp"
+#include "ipc/epoll/event-poll.hpp"
 
+#include <atomic>
 #include <string>
+#include <pthread.h>
 
 
-namespace security_containers {
+namespace vasum {
 
 
 class Server {
 public:
-    Server(const std::string& configPath, bool runAsRoot = true);
-    virtual ~Server();
-
-    /**
-     * Set needed caps, groups and drop root privileges.
-     */
-    static bool prepareEnvironment(const std::string& configPath, bool runAsRoot);
+    Server(const std::string& configPath);
 
     /**
-     * Starts all the containers and blocks until SIGINT, SIGTERM or SIGUSR1
+     * Starts all the zones and blocks until SIGINT, SIGTERM or SIGUSR1
      */
-    void run();
+    void run(bool asRoot);
 
     /**
      * Reload the server by launching execve on itself if SIGUSR1 was sent to server.
@@ -59,12 +60,34 @@ public:
      * Equivalent of sending SIGINT or SIGTERM signal
      */
     void terminate();
+
+    /**
+     * Check server runtime environment
+    */
+    static bool checkEnvironment();
+
 private:
+    bool mIsRunning;
+    bool mIsUpdate;
     std::string mConfigPath;
+    utils::ScopedGlibLoop loop;
+    ipc::epoll::EventPoll mEventPoll;
+    utils::SignalFD mSignalFD;
+    ZonesManager mZonesManager;
+    ::pthread_t mDispatchingThread;
+
+    /**
+     * Set needed caps, groups and drop root privileges.
+     */
+    static bool prepareEnvironment(const std::string& configPath, bool runAsRoot);
+
+    void handleUpdate();
+    void handleStop();
+
 };
 
 
-} // namespace security_containers
+} // namespace vasum
 
 
 #endif // SERVER_SERVER_HPP