29 |
|
|
30 |
/* Private prototypes */ |
/* Private prototypes */ |
31 |
static void _gcppl(Port_T*); |
static void _gcppl(Port_T*); |
32 |
static void _gcpl(Process_T*); |
static void _gcpl(Service_T*); |
33 |
static void _gcpcl(Checksum_T*); |
static void _gcpcl(Checksum_T*); |
34 |
static void _gcpql(Resource_T*); |
static void _gcpql(Resource_T*); |
35 |
static void _gcppil(ProcInfo_T*); |
static void _gcppil(ProcInfo_T*); |
56 |
void gc() { |
void gc() { |
57 |
|
|
58 |
gc_protocols(); |
gc_protocols(); |
59 |
if(processlist) _gcpl(&processlist); |
if(servicelist) _gcpl(&servicelist); |
60 |
if(Run.mygroup) free(Run.mygroup); |
if(Run.mygroup) free(Run.mygroup); |
61 |
|
|
62 |
} |
} |
63 |
|
|
64 |
|
|
65 |
void gc_process(Process_T *p) { |
void gc_service(Service_T *s) { |
66 |
|
|
67 |
int i; |
int i; |
68 |
|
|
69 |
ASSERT(p); |
ASSERT(s&&*s); |
70 |
|
|
71 |
if((*p)->portlist) { |
if((*s)->portlist) { |
72 |
|
|
73 |
_gcppl(&(*p)->portlist); |
_gcppl(&(*s)->portlist); |
74 |
|
|
75 |
} |
} |
76 |
|
|
77 |
if((*p)->checksumlist) { |
if((*s)->checksumlist) { |
78 |
|
|
79 |
_gcpcl(&(*p)->checksumlist); |
_gcpcl(&(*s)->checksumlist); |
80 |
|
|
81 |
} |
} |
82 |
|
|
83 |
if((*p)->maillist) { |
if((*s)->maillist) { |
84 |
|
|
85 |
gc_mail_list(&(*p)->maillist); |
gc_mail_list(&(*s)->maillist); |
86 |
|
|
87 |
} |
} |
88 |
|
|
89 |
if((*p)->resourcelist) { |
if((*s)->resourcelist) { |
90 |
|
|
91 |
_gcpql(&(*p)->resourcelist); |
_gcpql(&(*s)->resourcelist); |
92 |
|
|
93 |
} |
} |
94 |
|
|
95 |
if((*p)->procinfo) { |
if((*s)->procinfo) { |
96 |
|
|
97 |
_gcppil(&(*p)->procinfo); |
_gcppil(&(*s)->procinfo); |
98 |
|
|
99 |
} |
} |
100 |
|
|
101 |
if((*p)->devinfo) { |
if((*s)->devinfo) { |
102 |
|
|
103 |
_gcpdil(&(*p)->devinfo); |
_gcpdil(&(*s)->devinfo); |
104 |
|
|
105 |
} |
} |
106 |
|
|
107 |
if((*p)->timestamplist) { |
if((*s)->timestamplist) { |
108 |
|
|
109 |
_gcptl(&(*p)->timestamplist); |
_gcptl(&(*s)->timestamplist); |
110 |
|
|
111 |
} |
} |
112 |
|
|
113 |
if((*p)->dependantlist) { |
if((*s)->dependantlist) { |
114 |
|
|
115 |
_gcpdl(&(*p)->dependantlist); |
_gcpdl(&(*s)->dependantlist); |
116 |
|
|
117 |
} |
} |
118 |
|
|
119 |
free((*p)->name); |
free((*s)->name); |
120 |
free((*p)->path); |
free((*s)->path); |
121 |
free((*p)->group); |
free((*s)->group); |
122 |
|
|
123 |
if((*p)->start) { |
if((*s)->start) { |
124 |
for(i= 0; (*p)->start->arg[i]; i++) |
for(i= 0; (*s)->start->arg[i]; i++) |
125 |
free((*p)->start->arg[i]); |
free((*s)->start->arg[i]); |
126 |
for(i= 0; (*p)->start->env[i]; i++) |
for(i= 0; (*s)->start->env[i]; i++) |
127 |
free((*p)->start->env[i]); |
free((*s)->start->env[i]); |
128 |
free((*p)->start); |
free((*s)->start); |
129 |
} |
} |
130 |
|
|
131 |
if((*p)->stop) { |
if((*s)->stop) { |
132 |
for(i= 0; (*p)->stop->arg[i]; i++) |
for(i= 0; (*s)->stop->arg[i]; i++) |
133 |
free((*p)->stop->arg[i]); |
free((*s)->stop->arg[i]); |
134 |
for(i= 0; (*p)->stop->env[i]; i++) |
for(i= 0; (*s)->stop->env[i]; i++) |
135 |
free((*p)->stop->env[i]); |
free((*s)->stop->env[i]); |
136 |
free((*p)->stop); |
free((*s)->stop); |
137 |
} |
} |
138 |
|
|
139 |
(*p)->next= NULL; |
(*s)->next= NULL; |
140 |
|
|
141 |
pthread_mutex_destroy(&(*p)->mutex); |
pthread_mutex_destroy(&(*s)->mutex); |
142 |
|
|
143 |
free(*p); |
free(*s); |
144 |
|
|
145 |
|
*s= NULL; |
146 |
|
|
147 |
} |
} |
148 |
|
|
168 |
/* ----------------------------------------------------------------- Private */ |
/* ----------------------------------------------------------------- Private */ |
169 |
|
|
170 |
|
|
171 |
static void _gcpl(Process_T *p) { |
static void _gcpl(Service_T *s) { |
172 |
|
|
173 |
ASSERT(p); |
ASSERT(s&&*s); |
174 |
|
|
175 |
if((*p)->next) { |
if((*s)->next) { |
176 |
|
|
177 |
_gcpl(&(*p)->next); |
_gcpl(&(*s)->next); |
178 |
|
|
179 |
} |
} |
180 |
|
|
181 |
gc_process(&(*p)); |
gc_service(&(*s)); |
182 |
*p= NULL; |
*s= NULL; |
183 |
|
|
184 |
} |
} |
185 |
|
|
186 |
|
|
187 |
static void _gcppl(Port_T *p) { |
static void _gcppl(Port_T *s) { |
188 |
|
|
189 |
ASSERT(p); |
ASSERT(s&&*s); |
190 |
|
|
191 |
if((*p)->next) { |
if((*s)->next) { |
192 |
|
|
193 |
_gcppl(&(*p)->next); |
_gcppl(&(*s)->next); |
194 |
|
|
195 |
} |
} |
196 |
|
|
197 |
free((*p)->hostname); |
free((*s)->hostname); |
198 |
free((*p)->request); |
free((*s)->request); |
199 |
free((*p)->pathname); |
free((*s)->pathname); |
200 |
free((*p)->address); |
free((*s)->address); |
201 |
free((*p)->certmd5); |
free((*s)->certmd5); |
202 |
|
|
203 |
delete_ssl_socket((*p)->ssl); |
delete_ssl_socket((*s)->ssl); |
204 |
free(*p); |
free(*s); |
205 |
*p= NULL; |
*s= NULL; |
206 |
|
|
207 |
} |
} |
208 |
|
|
209 |
|
|
210 |
static void _gcpcl(Checksum_T *p) { |
static void _gcpcl(Checksum_T *s) { |
211 |
|
|
212 |
ASSERT(p); |
ASSERT(s&&*s); |
213 |
|
|
214 |
if((*p)->next) { |
if((*s)->next) { |
215 |
|
|
216 |
_gcpcl(&(*p)->next); |
_gcpcl(&(*s)->next); |
217 |
|
|
218 |
} |
} |
219 |
|
|
220 |
free((*p)->file); |
free((*s)->file); |
221 |
free((*p)->md5); |
free((*s)->md5); |
222 |
free(*p); |
free(*s); |
223 |
*p= NULL; |
*s= NULL; |
224 |
|
|
225 |
} |
} |
226 |
|
|