some memory leakage fixes

This commit is contained in:
whottgen 2006-09-28 13:09:36 +00:00
parent b244466563
commit e02ae5d350
5 changed files with 20 additions and 9 deletions

View File

@ -1,3 +1,3 @@
SUBDIRS = libsmmapdfw smmapd verify_worker test_worker cyrus_worker doc m4
SUBDIRS = libsmmapdfw verify_worker test_worker cyrus_worker smmapd doc m4

View File

@ -87,7 +87,7 @@ RC = @RC@
STRIP = @STRIP@
VERSION = @VERSION@
SUBDIRS = libsmmapdfw smmapd verify_worker test_worker cyrus_worker doc m4
SUBDIRS = libsmmapdfw verify_worker test_worker cyrus_worker smmapd doc m4
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h

View File

@ -230,7 +230,10 @@ int unregister_all() {
classes = classes->next;
unregister_class(cf);
dlclose(cf->dl_handle);
if (NULL != cf->dl_handle)
dlclose(cf->dl_handle);
free(cf);
}
}
@ -241,10 +244,10 @@ int register_all() {
}
int register_worker(char *worker_name) {
void *dl_handle;
class_descriptor_t * class_descriptor;
void *dl_handle = NULL;
class_descriptor_t * class_descriptor = NULL;
char *cfg_plugin_dir, *cfg_plugins, *cfg_plugin, *cfg_obj, *cfg_plugin_name;
char *obj_name;
char *obj_name = NULL;
const char *err_msg;
int err;
int id = 0;

View File

@ -403,8 +403,8 @@ int server() {
}
#endif /* ENABLE_NETSNMP */
while (getStatCounter(globalStatCounter, STAT_CNT_ACCEPTED) < 3) {
// while (1) {
// while (getStatCounter(globalStatCounter, STAT_CNT_ACCEPTED) < 1000) {
while (1) {
syslog(LOG_DEBUG, "server: Waiting for connection");
clientSock = accept(serverSock, (struct sockaddr *) &clientAddr, &clientAddrLen);

View File

@ -162,6 +162,7 @@ struct worker_thread_s {
int checker_cnt;
ht_queue_t *terminator_queue;
verify_work_handle_t *vwh;
char* rememberPropagatedOutput;
};
typedef struct worker_thread_s worker_thread_t;
@ -315,6 +316,9 @@ int verify_work_destroy(void *handle, void *work_handle) {
queue_destroy(wt->checker_terminator_queue);
free(wt->checker_terminator_queue);
if (NULL != wt->rememberPropagatedOutput)
free(wt->rememberPropagatedOutput);
free(wt);
@ -470,6 +474,7 @@ int verify_work(void *handle, void *work_handle, char *input, htbuffer_t *output
wt->mutex = vwh->result_mutex;
wt->cond = vwh->result_cond;
wt->result = vwh->result;
wt->rememberPropagatedOutput = NULL;
wt->checker_terminator_queue = (ht_queue_t*) htmalloc(sizeof(ht_queue_t));
queue_init(wt->checker_terminator_queue);
wt->checker_cnt = 0;
@ -505,7 +510,9 @@ int verify_work(void *handle, void *work_handle, char *input, htbuffer_t *output
// snprintf(output, ANSWER_BUFSIZE, vwh->result->output);
htbuffer_strcpy(output, vwh->result->output);
free(vwh->result->output);
/* this belongs to the worker thread, it will be freed when the worker thread is cleaned up */
/* free(vwh->result->output); */
/* vwh->result->output = NULL; */
return vwh->result->result;
}
@ -842,6 +849,7 @@ static void *worker_thread(void *arg) {
/* we can write the result */
wt->result->output = (char*) htmalloc(sizeof(char) * (strlen(wt->output)+15)); /* enough for the output
plus <><> and prefix */
wt->rememberPropagatedOutput = wt->result->output;
switch (result) {
case SMM_LOCAL_TEMP_NOK:
sprintf(wt->result->output, "<TNOK><%s>", wt->output);