00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include <stdio.h>
00023 #include <stdlib.h>
00024
00025 #include "monitor.h"
00026 #include "protocol.h"
00027 #include "ssl.h"
00028
00029
00030
00031 static void _gcppl(Port_T*);
00032 static void _gcpl(Process_T*);
00033 static void _gcpcl(Checksum_T*);
00034 static void _gcpql(Resource_T*);
00035 static void _gcppil(ProcInfo_T*);
00036 static void _gcptl(Timestamp_T*);
00037 static void _gcpdl(Dependant_T *d);
00038
00039
00052
00053
00054
00055 void gc() {
00056
00057 gc_protocols();
00058 if(processlist) _gcpl(&processlist);
00059 if(Run.mygroup) free(Run.mygroup);
00060
00061 }
00062
00063
00064 void gc_process(Process_T *p) {
00065
00066 int i;
00067
00068 ASSERT(p);
00069
00070 if((*p)->portlist) {
00071
00072 _gcppl(&(*p)->portlist);
00073
00074 }
00075
00076 if((*p)->checksumlist) {
00077
00078 _gcpcl(&(*p)->checksumlist);
00079
00080 }
00081
00082 if((*p)->maillist) {
00083
00084 gc_mail_list(&(*p)->maillist);
00085
00086 }
00087
00088 if((*p)->resourcelist) {
00089
00090 _gcpql(&(*p)->resourcelist);
00091
00092 }
00093
00094 if((*p)->procinfo) {
00095
00096 _gcppil(&(*p)->procinfo);
00097
00098 }
00099
00100 if((*p)->timestamplist) {
00101
00102 _gcptl(&(*p)->timestamplist);
00103
00104 }
00105
00106 if((*p)->dependantlist) {
00107
00108 _gcpdl(&(*p)->dependantlist);
00109
00110 }
00111
00112 free((*p)->name);
00113 free((*p)->pidfile);
00114 free((*p)->group);
00115 if((*p)->start) {
00116 for(i= 0; (*p)->start->arg[i]; i++)
00117 free((*p)->start->arg[i]);
00118 free((*p)->start);
00119 }
00120 if((*p)->stop) {
00121 for(i= 0; (*p)->stop->arg[i]; i++)
00122 free((*p)->stop->arg[i]);
00123 free((*p)->stop);
00124 }
00125 (*p)->next= NULL;
00126
00127 pthread_mutex_destroy(&(*p)->mutex);
00128
00129 free(*p);
00130
00131 }
00132
00133
00134 void gc_mail_list(Mail_T *m) {
00135
00136 ASSERT(m);
00137
00138 if((*m)->next)
00139 gc_mail_list(&(*m)->next);
00140
00141 free((*m)->to);
00142 free((*m)->from);
00143 free((*m)->subject);
00144 free((*m)->message);
00145 free((*m)->opt_message);
00146 free(*m);
00147 *m= NULL;
00148
00149 }
00150
00151
00152
00153
00154
00155 static void _gcpl(Process_T *p) {
00156
00157 ASSERT(p);
00158
00159 if((*p)->next) {
00160
00161 _gcpl(&(*p)->next);
00162
00163 }
00164
00165 gc_process(&(*p));
00166 *p= NULL;
00167
00168 }
00169
00170
00171 static void _gcppl(Port_T *p) {
00172
00173 ASSERT(p);
00174
00175 if((*p)->next) {
00176
00177 _gcppl(&(*p)->next);
00178
00179 }
00180
00181 free((*p)->hostname);
00182 free((*p)->request);
00183 free((*p)->pathname);
00184 free((*p)->address);
00185 free((*p)->certmd5);
00186
00187 delete_ssl_socket((*p)->ssl);
00188 free(*p);
00189 *p= NULL;
00190
00191 }
00192
00193
00194 static void _gcpcl(Checksum_T *p) {
00195
00196 ASSERT(p);
00197
00198 if((*p)->next) {
00199
00200 _gcpcl(&(*p)->next);
00201
00202 }
00203
00204 free((*p)->file);
00205 free((*p)->md5);
00206 free(*p);
00207 *p= NULL;
00208
00209 }
00210
00211
00212 static void _gcpql(Resource_T *q) {
00213
00214 ASSERT(q);
00215
00216 if((*q)->next) {
00217
00218 _gcpql(&(*q)->next);
00219
00220 }
00221
00222 free(*q);
00223 *q= NULL;
00224
00225 }
00226
00227
00228 static void _gcppil(ProcInfo_T *pi) {
00229
00230 ASSERT(pi);
00231
00232 free(*pi);
00233 *pi= NULL;
00234
00235 }
00236
00237
00238 static void _gcptl(Timestamp_T *p) {
00239
00240 ASSERT(p);
00241
00242 if((*p)->next) {
00243
00244 _gcptl(&(*p)->next);
00245
00246 }
00247
00248 free((*p)->pathname);
00249 free(*p);
00250 *p= NULL;
00251
00252 }
00253
00254
00255 static void _gcpdl(Dependant_T *d) {
00256
00257 ASSERT(d);
00258
00259 if((*d)->next) {
00260
00261 _gcpdl(&(*d)->next);
00262
00263 }
00264
00265 free((*d)->dependant);
00266 free(*d);
00267 *d= NULL;
00268
00269 }