1
0
Fork 0

Misc. memory leak fixes (thanks to lool@dooz.org

This commit is contained in:
bagyenda 2006-01-11 05:29:21 +00:00
parent 0b9802fce3
commit 5c1107594d
11 changed files with 32 additions and 1 deletions

View File

@ -231,6 +231,7 @@ void mms_strings_init(void)
void mms_strings_shutdown(void)
{
wsp_strings_shutdown();
/* If we were initialized more than once, then wait for more than
* one shutdown. */
if (initialized > 1) {

View File

@ -39,4 +39,5 @@ long mms_string_to_versioned_##name(Octstr *ostr, int version);
#include "wap/wsp_strings.h"
void mms_strings_init(void);
void mms_strings_shutdown(void);
#endif

View File

@ -216,6 +216,12 @@ void mms_lib_init(void)
}
void mms_lib_shutdown(void)
{
mms_strings_shutdown();
gwlib_shutdown();
}
static void strip_quotes(Octstr *s)
{
int l = s ? octstr_len(s) : 0;

View File

@ -63,6 +63,7 @@ Octstr *mms_find_sender_ip(List *request_hdrs, Octstr *ip_header, Octstr *ip, in
extern Octstr *mms_isodate(time_t t);
void mms_lib_init(void);
void mms_lib_shutdown(void);
/* get content type while stripping params. If any param is null, fails. */
int get_content_type(List *hdrs, Octstr **type, Octstr **params);

View File

@ -508,6 +508,7 @@ int main(int argc, char *argv[])
if (sendmms_port.port > 0)
gwthread_join(sthread);
sleep(2);
mms_lib_shutdown();
return 0;
}

View File

@ -26,7 +26,11 @@ static void *mms_billingmodule_init(char *settings)
static int mms_billingmodule_fini(void *module_data)
{
return 0;
if (script) {
octstr_destroy(script);
script = NULL;
}
return 0;
}
static double mms_billmsg(Octstr *from, List *to, unsigned long msg_size, Octstr *vaspid, void *module_data)

View File

@ -27,6 +27,11 @@ static int mms_detokenizer_init(char *settings)
static int mms_detokenizer_fini(void)
{
if (script) {
octstr_destroy(script);
script = NULL;
}
return 0;
}

View File

@ -64,6 +64,8 @@ int main(int argc, char *argv[])
/* Load settings. */
settings = mms_load_mmsc_settings(cfg, &proxyrelays);
cfg_destroy(cfg);
if (!settings)
panic(0, "No global MMSC configuration!");
@ -80,6 +82,7 @@ int main(int argc, char *argv[])
(ttype == TPLMN && !does_prefix_match(settings->email2mmsrelay_prefixes, xto))) {
error(0, " Not allowed to send to this recipient %s!",
xto ? octstr_get_cstr(xto) : "(null)");
mms_lib_shutdown();
return -1;
}
@ -88,11 +91,13 @@ int main(int argc, char *argv[])
if (!email || octstr_len(email) == 0) {
error(0, "Empty email message!");
mms_lib_shutdown();
return -1;
}
if ((mm = mime_octstr_to_entity(email)) == NULL) {
error(0, "Unable to decode mime entity!");
mms_lib_shutdown();
return -1;
}
octstr_destroy(email);
@ -112,6 +117,7 @@ int main(int argc, char *argv[])
if (!msg) {
error(0, "Unable to create MM!");
mms_lib_shutdown();
return -1;
}
@ -309,6 +315,7 @@ int main(int argc, char *argv[])
}
}
mms_destroy(msg);
mms_lib_shutdown();
return 0;

View File

@ -224,6 +224,7 @@ int main(int argc, char *argv[])
sleep(2); /* Give them time to shut down. */
mms_stop_profile_engine();
sleep(2); /* Give them time to shut down. */
mms_lib_shutdown();
return 0;
}

View File

@ -84,6 +84,7 @@ int main(int argc, char *argv[])
mms_stop_profile_engine(); /* Stop profile stuff. */
sleep(2); /* Wait for them to die. */
mms_lib_shutdown();
return 0;
};

View File

@ -105,6 +105,8 @@ int main(int argc, char *argv[])
/* Load settings. */
settings = mms_load_mmsc_settings(cfg, &proxyrelays);
cfg_destroy(cfg);
if (!settings)
panic(0, "No global MMSC configuration!");
@ -155,5 +157,6 @@ int main(int argc, char *argv[])
printf("Queued: %s, mmbox=%s\n",
octstr_get_cstr(s), mmbox ? octstr_get_cstr(mmbox) : "");
octstr_destroy(s);
mms_lib_shutdown();
return 0;
}