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
76
77
78
|
#include <unistd.h>
#include <libglouglou.h>
#include "glougloud.h"
struct glougloud_probes {
int pid;
struct event_base *evb;
struct modules *mods;
redisAsyncContext *rc;
};
struct glougloud *_ggd;
struct glougloud_probes *_probes;
void cb_connect(const redisAsyncContext *c, int status)
{
if (status != REDIS_OK) {
log_warn("redis error: %s", c->errstr);
return;
}
log_info("redis connected\n");
}
void cb_disconnect(const redisAsyncContext *c, int status)
{
if (status != REDIS_OK) {
log_warn("redis error: %s", c->errstr);
return;
}
log_info("redis disconnected");
}
int
prb_handle_conn(struct gg_server *srv, struct gg_user *usr)
{
// XXX
return 0;
}
int
prb_handle_packet(struct gg_server *srv, struct gg_user *usr, struct gg_packet *pkt)
{
// XXX
return 0;
}
int
probes_init(struct glougloud *ggd) {
_ggd = ggd;
_probes = xcalloc(1, sizeof(struct glougloud_probes));
_probes->pid = fork();
if (_probes->pid > 0)
return 0;
droppriv(GLOUGLOUD_USER_PROBES, 1, NULL);
_probes->evb = event_base_new();
_probes->mods = modules_load(GLOUGLOUD_MOD_PATH, NULL);
_probes->rc = redis_connect(_probes->evb, cb_connect, cb_disconnect);
// XXX libglouglou gg_server
_probes->server = gg_server_start(_probes->evb,
ggd->probes.serv_ip, ggd->probes.serv_port,
prb_handle_conn, prb_handle_packet, NULL);
event_base_dispatch(_probes->evb);
gg_server_stop(_probes);
return 0;
}
void
probes_shutdown(void) {
}
|