-
Notifications
You must be signed in to change notification settings - Fork 388
Expand file tree
/
Copy pathSessionProcessManager.h
More file actions
67 lines (52 loc) · 1.86 KB
/
SessionProcessManager.h
File metadata and controls
67 lines (52 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2014 Emweb bvba, Herent, Belgium.
*
* All rights reserved.
*/
#ifndef HTTP_SESSION_PROCESS_MANAGER_HPP
#define HTTP_SESSION_PROCESS_MANAGER_HPP
#include "../web/Configuration.h"
#include "SessionProcess.h"
#include "Wt/WServer.h"
#include "Wt/AsioWrapper/steady_timer.hpp"
namespace http {
namespace server {
typedef std::map<std::string, std::shared_ptr<SessionProcess> > SessionMap;
typedef std::vector<std::shared_ptr<SessionProcess> > SessionProcessList;
/// For dedicated processes: maps session ids to child processes and their sockets
class SessionProcessManager
{
public:
SessionProcessManager(asio::io_service &ioService,
const Wt::Configuration& configuration);
SessionProcessManager(const SessionProcessManager&) = delete;
SessionProcessManager &operator=(const SessionProcessManager&) = delete;
void stop();
bool tryToIncrementSessionCount();
const std::shared_ptr<SessionProcess>& sessionProcess(std::string sessionId);
void addPendingSessionProcess(const std::shared_ptr<SessionProcess>& process);
void addSessionProcess(std::string sessionId,
const std::shared_ptr<SessionProcess>& process);
std::vector<Wt::WServer::SessionInfo> sessions() const;
private:
void processDeadChildren(Wt::AsioWrapper::error_code ec);
#ifndef WT_WIN32
void removeSessionForPid(pid_t cpid);
#endif
#ifdef WT_THREADED
mutable std::mutex sessionsMutex_;
#endif // WT_THREADED
SessionProcessList pendingProcesses_; // Processes that have started up, but are not mapped to a session yet
SessionMap sessions_;
#if !defined(WT_WIN32) && BOOST_VERSION >= 104700
asio::signal_set signals_;
#else
asio::steady_timer timer_;
#endif
int numSessions_;
const Wt::Configuration &configuration_;
};
} // namespace server
} // namespace http
#endif // HTTP_SESSION_PROCESS_MANAGER_HPP