Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
68
69
70
71
72
73
74
75
#ifndef GDRIDD_LISTENER_H
#define GDRIDD_LISTENER_H
 
#include <set>
#include <mutex>
#include "dgrid.h"
#include "dgrid_thread.h"
#include <sys/socket.h>
 
namespace DGrid {
 
class DGriddChild;
 
class DGriddListener: public DGriddThread
{
public:
    DGriddListener();
    virtual ~DGriddListener();
 
    // start on local UNIX socket
    bool start(const std::string& path);
    // start on TCP port
    bool start(const std::string& addr, const uint16_t port);
    void childFinished(DGriddThread*);
    virtual void showStats();
    uint16_t connectedClients();
 
protected:
    virtual void run();
    void acceptConnection(int listenfd);
    virtual DGriddChild* createChild() = 0;
 
private:
    void stopChilds();
    void cleanupFinished();
    void setListenAddress(const std::string& path);
    void setListenAddress(const std::string& addr, const uint16_t port);
 
    sa_family_t address_family;
    std::string sock_path;
    std::string inet_addr;
    uint16_t inet_port;
    std::mutex childs_mutex;
    std::set<DGriddThread*> childs;
 
//    std::mutex childs_finished_mutex;
//    std::set<DGriddThread*> childs_finished;
};
 
class DGriddClientListener: public DGriddListener
{
public:
    DGriddClientListener();
    virtual ~DGriddClientListener();
    virtual void showStats();
 
protected:
    virtual DGriddChild* createChild();
};
 
class DGriddNodeListener: public DGriddListener
{
public:
    DGriddNodeListener();
    virtual ~DGriddNodeListener();
    virtual void showStats();
 
protected:
    virtual DGriddChild* createChild();
};
 
 
} // namespace DGrid
 
#endif // GDRIDD_LISTENER_H