Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
server.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Contact: Jan Olszak (j.olszak@samsung.com)
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License
17  */
18 
26 #ifndef SERVER_SERVER_HPP
27 #define SERVER_SERVER_HPP
28 
29 #include "zones-manager.hpp"
30 
31 #include "utils/latch.hpp"
32 #include "utils/signalfd.hpp"
33 #include "utils/glib-loop.hpp"
35 
36 #include <atomic>
37 #include <string>
38 #include <pthread.h>
39 
40 
41 namespace vasum {
42 
43 
44 class Server {
45 public:
46  Server(const std::string& configPath);
47 
51  void run(bool asRoot);
52 
56  void reloadIfRequired(char* argv[]);
57 
62  void terminate();
63 
67  static bool checkEnvironment();
68 
69 private:
70  bool mIsRunning;
71  bool mIsUpdate;
72  std::string mConfigPath;
77  ::pthread_t mDispatchingThread;
78 
82  static bool prepareEnvironment(const std::string& configPath, bool runAsRoot);
83 
84  void handleUpdate();
85  void handleStop();
86 
87 };
88 
89 
90 } // namespace vasum
91 
92 
93 #endif // SERVER_SERVER_HPP
bool mIsRunning
Definition: server.hpp:70
C++ epoll wrapper.
static bool checkEnvironment()
Check server runtime environment.
Definition: server.cpp:140
void reloadIfRequired(char *argv[])
Reload the server by launching execve on itself if SIGUSR1 was sent to server.
Definition: server.cpp:121
cargo::ipc::epoll::EventPoll mEventPoll
Definition: server.hpp:74
static bool prepareEnvironment(const std::string &configPath, bool runAsRoot)
Set needed caps, groups and drop root privileges.
Definition: server.cpp:207
Declaration of the class for managing many zones.
Definition: server.hpp:44
Signalfd wrapper.
Glib loop controller.
Definition: glib-loop.hpp:41
Server(const std::string &configPath)
Definition: server.cpp:79
utils::ScopedGlibLoop loop
Definition: server.hpp:73
void run(bool asRoot)
Starts all the zones and blocks until SIGINT, SIGTERM or SIGUSR1.
Definition: server.cpp:108
Definition: zones-manager.hpp:51
utils::SignalFD mSignalFD
Definition: server.hpp:75
void handleUpdate()
Definition: server.cpp:92
SignalFD takes control over handling signals sent to the thread.
Definition: signalfd.hpp:47
ZonesManager mZonesManager
Definition: server.hpp:76
C++ wrapper of glib main loop.
bool mIsUpdate
Definition: server.hpp:71
Synchronization latch.
void handleStop()
Definition: server.cpp:101
This class waits on registered file descriptor for events.
Definition: event-poll.hpp:47
::pthread_t mDispatchingThread
Definition: server.hpp:77
void terminate()
Terminates the server.
Definition: server.cpp:129
std::string mConfigPath
Definition: server.hpp:72