Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
62f9394b04ef4d65b434e05d31ec6f69ae631609
[simgrid.git] / src / mc / Server.hpp
1 /* Copyright (c) 2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SIMGRID_MC_SERVER_HPP
8 #define SIMGRID_MC_SERVER_HPP
9
10 #include <poll.h>
11
12 #include <sys/signalfd.h>
13 #include <sys/types.h>
14
15 #include <xbt/misc.h>
16 #include <xbt/base.h>
17  
18 #include "src/mc/Process.hpp"
19 #include "mc_exit.h"
20
21 namespace simgrid {
22 namespace mc {
23
24 class Server {
25 private:
26   pid_t pid;
27   int socket;
28   struct pollfd fds[2];
29 public:
30   Server(pid_t pid, int socket);
31   void start();
32   void shutdown();
33   void resume(simgrid::mc::Process& process);
34   void loop();
35   bool handle_events();
36   void wait_client(simgrid::mc::Process& process);
37   void simcall_handle(simgrid::mc::Process& process, unsigned long pid, int value);
38 private:
39   bool handle_message(char* buffer, ssize_t size);
40   void handle_signals();
41   void handle_waitpid();
42   void on_signal(const struct signalfd_siginfo* info);
43 };
44
45 extern Server* server;
46
47 }
48 }
49
50 #endif