diff --git a/mbuni/mmlib/mms_queue.c b/mbuni/mmlib/mms_queue.c index 142ece6..83d25b8 100644 --- a/mbuni/mmlib/mms_queue.c +++ b/mbuni/mmlib/mms_queue.c @@ -1128,8 +1128,8 @@ static void mms_queue_run(char *dir, goto qloop; } } - if (xdir) - octstr_destroy(xdir); + + octstr_destroy(xdir); if (*rstop) break; qloop: @@ -1157,7 +1157,7 @@ static int mms_cleanup_queue_module(void) } /* export functions... */ -MmsQueueHandlerFuncs qfuncs = { +MmsQueueHandlerFuncs default_qfuncs = { mms_init_queue_module, mms_init_queue_dir, mms_cleanup_queue_module, diff --git a/mbuni/mmlib/mms_queue.h b/mbuni/mmlib/mms_queue.h index 1967315..db2d5fa 100644 --- a/mbuni/mmlib/mms_queue.h +++ b/mbuni/mmlib/mms_queue.h @@ -147,9 +147,11 @@ typedef struct MmsQueueHandlerFuncs { int (*mms_queue_free_env)(MmsEnvelope *e); } MmsQueueHandlerFuncs; -/* Module must export this symbol: */ -extern MmsQueueHandlerFuncs qfuncs; +/* Module must export this symbol: + * extern MmsQueueHandlerFuncs qfuncs; + */ +extern MmsQueueHandlerFuncs default_qfuncs; /* default queue handler module, file-based */ /* Utility functions, generally defined. */ /* Creates the queue envelope object, returns it. */ MmsEnvelope *mms_queue_create_envelope(Octstr *from, List *to, diff --git a/mbuni/mmsbox/mmsbox.c b/mbuni/mmsbox/mmsbox.c index d542fff..09c8eb1 100644 --- a/mbuni/mmsbox/mmsbox.c +++ b/mbuni/mmsbox/mmsbox.c @@ -1062,8 +1062,8 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, http_header_add(hdrs, "X-Mbuni-TransactionID", octstr_get_cstr(otransid)); if (distro) /* always add distrib */ - http_header_add(hdrs, "X-Mbuni-DistributionIndicator", octstr_get_cstr(distro)); - + http_header_add(hdrs, "X-Mbuni-DistributionIndicator", + (octstr_str_case_compare(distro, "true") == 0) ? "true" : "false"); if (passthro_headers && reply_headers) { /* if user wants passthro headers, get them and add them. */ int n = gwlist_len(reply_headers); int i; diff --git a/mbuni/mmsbox/mmsbox_cfg.c b/mbuni/mmsbox/mmsbox_cfg.c index 253c3ea..13a305b 100644 --- a/mbuni/mmsbox/mmsbox_cfg.c +++ b/mbuni/mmsbox/mmsbox_cfg.c @@ -107,7 +107,7 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func) octstr_get_cstr(gdir), strerror(errno)); if ((qfs = load_module(grp, "queue-manager-module", "qfuncs")) == NULL) { - qfs = &qfuncs; /* default queue handler. */ + qfs = &default_qfuncs; /* default queue handler. */ qfs->mms_init_queue_module(gdir); } else { Octstr *s = _mms_cfg_getx(grp, octstr_imm("queue-module-init-data")); @@ -127,8 +127,11 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func) panic(0, "Failed to initialise outgoing mmsbox queue directory: %s - %s!", octstr_get_cstr(outgoing_qdir), strerror(errno)); - if ((dlr_dir = qfuncs.mms_init_queue_dir("mmsbox_dlr", &xx)) == NULL || - xx != 0) /* XXX still uses old-style file storage. */ + /* XXX still uses old-style file storage. */ + if (qfs != &default_qfuncs) + default_qfuncs.mms_init_queue_module(gdir); + if ((dlr_dir = default_qfuncs.mms_init_queue_dir("mmsbox_dlr", &xx)) == NULL || + xx != 0) panic(0, "Failed to initialise dlr storage directory: %s - %s!", octstr_get_cstr(dlr_dir), strerror(errno)); diff --git a/mbuni/mmsc/mmsc_cfg.c b/mbuni/mmsc/mmsc_cfg.c index 4f7ab3a..778f79d 100644 --- a/mbuni/mmsc/mmsc_cfg.c +++ b/mbuni/mmsc/mmsc_cfg.c @@ -72,6 +72,12 @@ static void *load_module(mCfgGrp *grp, char *config_key, char *symbolname, return retval; } +void mms_cleanup_mmsc_settings(MmscSettings *settings) +{ + /* eventually we will destroy the object. For now, we only cleanup queue module. */ + settings->qfs->mms_cleanup_queue_module(); +} + MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays) { Octstr *s; @@ -83,7 +89,7 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays) long port = -1; Octstr *from, *user, *pass; Octstr *qdir = NULL; - int i, n, xx; + int i, n, xx = 0; memset(m, 0, sizeof *m); @@ -123,7 +129,7 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays) octstr_get_cstr(qdir), strerror(errno)); if ((m->qfs = load_module(grp, "queue-manager-module", "qfuncs", NULL)) == NULL) { - m->qfs = &qfuncs; /* default queue handler. */ + m->qfs = &default_qfuncs; /* default queue handler. */ m->qfs->mms_init_queue_module(qdir); } else { Octstr *s = _mms_cfg_getx(grp, octstr_imm("queue-module-init-data")); diff --git a/mbuni/mmsc/mmsc_cfg.h b/mbuni/mmsc/mmsc_cfg.h index 3ab3b5a..ffceebc 100644 --- a/mbuni/mmsc/mmsc_cfg.h +++ b/mbuni/mmsc/mmsc_cfg.h @@ -107,6 +107,8 @@ typedef struct MmscSettings { /* Returns mmsc settings. */ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays); +/* do final cleanup. */ +void mms_cleanup_mmsc_settings(MmscSettings *settings); /* Returns list of MmsProxyRelay */ extern List *mms_proxy_relays(mCfg *cfg, Octstr *myhostname); diff --git a/mbuni/mmsc/mmsfromemail.c b/mbuni/mmsc/mmsfromemail.c index f04124d..b12a0a6 100644 --- a/mbuni/mmsc/mmsfromemail.c +++ b/mbuni/mmsc/mmsfromemail.c @@ -455,28 +455,20 @@ int main(int argc, char *argv[]) ack && octstr_str_case_compare(ack, "Yes") == 0) send_mm4_res(mtype+1, orig_sys, me, transid, err, newmsgid); - if (mm4_type) - octstr_destroy(mm4_type); - if (transid) - octstr_destroy(transid); - if (orig_sys) - octstr_destroy(orig_sys); - if (msgid) - octstr_destroy(msgid); - if (newmsgid) - octstr_destroy(newmsgid); - if (rstatus) - octstr_destroy(rstatus); - if (xto) - octstr_destroy(xto); - if (xfrom) - octstr_destroy(xfrom); - if (xproxy) - octstr_destroy(xproxy); + octstr_destroy(mm4_type); + octstr_destroy(transid); + octstr_destroy(orig_sys); + octstr_destroy(msgid); + octstr_destroy(newmsgid); + octstr_destroy(rstatus); + octstr_destroy(xto); + octstr_destroy(xfrom); + octstr_destroy(xproxy); octstr_destroy(me); mms_destroy(msg); + mms_cleanup_mmsc_settings(settings); mms_lib_shutdown(); return 0; diff --git a/mbuni/mmsc/mmsproxy.c b/mbuni/mmsc/mmsproxy.c index 205a8d5..895bdb4 100644 --- a/mbuni/mmsc/mmsproxy.c +++ b/mbuni/mmsc/mmsproxy.c @@ -230,6 +230,8 @@ 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_cleanup_mmsc_settings(settings); mms_lib_shutdown(); return 0; } diff --git a/mbuni/mmsc/mmsrelay.c b/mbuni/mmsc/mmsrelay.c index 1cda410..3d3f5af 100644 --- a/mbuni/mmsc/mmsrelay.c +++ b/mbuni/mmsc/mmsrelay.c @@ -85,6 +85,7 @@ int main(int argc, char *argv[]) mms_stop_profile_engine(); /* Stop profile stuff. */ sleep(2); /* Wait for them to die. */ + mms_cleanup_mmsc_settings(settings); mms_lib_shutdown(); return 0; }; diff --git a/mbuni/mmsc/mmssend.c b/mbuni/mmsc/mmssend.c index 3a17622..5df0fc9 100644 --- a/mbuni/mmsc/mmssend.c +++ b/mbuni/mmsc/mmssend.c @@ -170,9 +170,8 @@ int main(int argc, char *argv[]) octstr_get_cstr(s), mmbox ? octstr_get_cstr(mmbox) : ""); octstr_destroy(s); - if (h) - http_destroy_headers(h); - + http_destroy_headers(h); + mms_cleanup_mmsc_settings(settings); mms_lib_shutdown(); return 0; }