-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathsvhub.h
More file actions
107 lines (88 loc) · 2.19 KB
/
svhub.h
File metadata and controls
107 lines (88 loc) · 2.19 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <bits/types.h>
#define NAMELEN 19
#define NPROCS 40
#define NCONNS 10
#define NPREQS 10
#define STABLE_TRESHOLD 5
#define TIME_TO_RESTART 1
#define TIME_TO_SIGKILL 2
#define TIME_TO_SKIP 5
#define PAGE 4096
#define RINGSIZE 1024
#define P_DISABLED (1<<0)
#define P_SIGSTOP (1<<1)
#define P_SIGTERM (1<<2)
#define P_SIGKILL (1<<3)
#define P_RESTART (1<<4)
#define P_FAILED (1<<5)
#define P_STALE (1<<6)
#define P_STUCK (1<<7)
#define F_WAIT_PIDS (1<<0)
#define F_SETUP_CTRL (1<<1)
#define F_RELOAD_PROCS (1<<2)
#define F_CHECK_PROCS (1<<3)
#define F_TRIM_RING (1<<4)
#define F_UPDATE_PFDS (1<<5)
#define F_EXIT_LOOP (1<<6)
struct proc {
int pid;
uint8_t flags;
char name[NAMELEN];
time_t lastrun;
time_t lastsig;
int status;
int pipefd;
/* ring buffer */
short idx;
short ptr;
};
struct conn {
int fd;
int pid;
};
struct ucmsg;
extern void* origbrk;
extern const char* rbscript;
extern int ctrlfd;
extern char* confdir;
extern char** environ;
extern time_t passtime;
extern char* reboot;
extern struct proc procs[];
extern struct conn conns[];
extern int nprocs;
extern int nconns;
struct proc* firstrec(void);
struct proc* nextrec(struct proc* rc);
struct proc* find_by_name(char* name);
struct proc* find_by_pid(int pid);
struct proc* grab_proc_slot(void);
void free_proc_slot(struct proc* rc);
struct conn* grab_conn_slot(void);
void free_conn_slot(struct conn* cn);
void set_passtime(void);
int runtime(struct proc* rc);
void check_procs(void);
void update_poll_fds(void);
void wait_poll(void);
void wait_pids(void);
int setup_signals(void);
void setup_ctrl(void);
void accept_ctrl(int sfd);
void wakeupin(int ttw);
void request(int flag);
void handle_conn(struct conn* cn);
int stop_into(const char* script);
void notify_dead(int pid);
char* ring_buf_for(struct proc* rc);
int read_into_ring_buf(struct proc* rc, int fd);
void trim_ring_area(void);
void flush_ring_buf(struct proc* rc);
int reload_procs(void);
void report(char* msg, char* arg, int err);
void reprec(struct proc* rc, char* msg);
void setup_heap(void);
void* heap_alloc(int len);
void trim_heap(void* ptr);
void flush_heap(void);
void stop_all_procs(void);