1
2// vim:sw=2:ai
3
4/*
5 * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
6 * See COPYRIGHT.txt for details.
7 */
8
9#ifndef DENA_HSTCPSVR_HPP
10#define DENA_HSTCPSVR_HPP
11
12#include <memory>
13#include <string>
14#include <map>
15
16#include "mutex.hpp"
17#include "auto_file.hpp"
18#include "database.hpp"
19#include "config.hpp"
20#include "socket.hpp"
21
22namespace dena {
23
24struct hstcpsvr_shared_c {
25 config conf;
26 long num_threads;
27 long nb_conn_per_thread;
28 bool for_write_flag;
29 bool require_auth;
30 std::string plain_secret;
31 int readsize;
32 socket_args sockargs;
33 auto_file listen_fd;
34 database_ptr dbptr;
35 volatile unsigned int *thread_num_conns; /* 0 .. num_threads-1 */
36 hstcpsvr_shared_c() : num_threads(0), nb_conn_per_thread(100),
37 for_write_flag(false), require_auth(false), readsize(0),
38 thread_num_conns(0) { }
39};
40
41struct hstcpsvr_shared_v : public mutex {
42 int shutdown;
43 hstcpsvr_shared_v() : shutdown(0) { }
44};
45
46struct hstcpsvr_i;
47typedef std::auto_ptr<hstcpsvr_i> hstcpsvr_ptr;
48
49struct hstcpsvr_i {
50 virtual ~hstcpsvr_i() { }
51 virtual std::string start_listen() = 0;
52 static hstcpsvr_ptr create(const config& conf);
53};
54
55};
56
57#endif
58
59