forked from wangchuan3533/proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
55 lines (49 loc) · 1.01 KB
/
main.c
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
#include <stdio.h>
#include "define.h"
#include "dispatcher.h"
#include "worker.h"
#include "pusher.h"
#include "notifier.h"
int main(int argc, char **argv)
{
int ret, i;
dispatcher_t *d;
worker_t *w;
pusher_t *p;
#ifndef ECHO_SERVER
notifier_t *n;
#endif
#ifdef DUMP_DATA
setvbuf(stdout, NULL, _IONBF, 0);
#endif
for (i = 0; i < WORKER_NUM; i++) {
w = worker_create();
w->next = global.workers;
global.workers = w;
ret = worker_start(w);
if (ret != 0) {
err_quit("worker_start");
}
}
p = pusher_create();
ret = pusher_start(p);
if (ret != 0) {
err_quit("pusher_start");
}
#ifndef ECHO_SERVER
n = notifier_create();
n->pusher = p;
ret = notifier_start(n);
if (ret != 0) {
err_quit("notifier_start");
}
#endif
d = dispatcher_create();
ret = dispatcher_start(d);
if (ret != 0) {
err_quit("dispatcher_start");
}
for (;;)
sleep(1);
return 0;
}