From fe4c53f2bef27631f5ce20416a6eeef7df12b4ad Mon Sep 17 00:00:00 2001 From: bagyenda <> Date: Thu, 10 Jul 2008 09:46:58 +0000 Subject: [PATCH] misc. fixes --- mbuni/ChangeLog | 4 + mbuni/extras/pgsql-queue/mms_pgsql_queue.c | 69 +++++++++++------ mbuni/mmlib/mms_cfg.c | 2 +- mbuni/mmlib/mms_cfg.h | 2 +- mbuni/mmlib/mms_mm7soap.c | 2 +- mbuni/mmlib/mms_mm7soap.h | 2 +- mbuni/mmlib/mms_mmbox.c | 2 +- mbuni/mmlib/mms_mmbox.h | 2 +- mbuni/mmlib/mms_msg.c | 2 +- mbuni/mmlib/mms_msg.h | 2 +- mbuni/mmlib/mms_queue.c | 6 +- mbuni/mmlib/mms_queue.h | 4 +- mbuni/mmlib/mms_strings.c | 2 +- mbuni/mmlib/mms_strings.h | 2 +- mbuni/mmlib/mms_uaprof.c | 2 +- mbuni/mmlib/mms_uaprof.h | 2 +- mbuni/mmsbox/mmsbox.c | 2 +- mbuni/mmsbox/mmsbox.h | 2 +- mbuni/mmsbox/mmsbox_cfg.c | 88 ++++++++++++---------- mbuni/mmsbox/mmsbox_cfg.h | 3 +- mbuni/mmsbox/mmsbox_mmsc.h | 2 +- mbuni/mmsbox/mmsbox_mt_filter.c | 2 +- mbuni/mmsbox/mmsbox_mt_filter.h | 2 +- mbuni/mmsbox/mmsbox_resolve_shell.c | 2 +- mbuni/mmsbox/mmsbox_resolve_shell.h | 2 +- mbuni/mmsc/mms_billing.c | 2 +- mbuni/mmsc/mms_billing_shell.h | 2 +- mbuni/mmsc/mms_detokenize.c | 2 +- mbuni/mmsc/mms_detokenize.h | 2 +- mbuni/mmsc/mms_detokenize_shell.h | 2 +- mbuni/mmsc/mms_resolve.c | 2 +- mbuni/mmsc/mms_resolve.h | 2 +- mbuni/mmsc/mms_resolve_shell.c | 2 +- mbuni/mmsc/mms_resolve_shell.h | 2 +- mbuni/mmsc/mmsc_cfg.c | 6 +- mbuni/mmsc/mmsc_cfg.h | 2 +- mbuni/mmsc/mmsfromemail.c | 2 +- mbuni/mmsc/mmsglobalsender.c | 4 +- mbuni/mmsc/mmsmobilesender.c | 4 +- mbuni/mmsc/mmsproxy.c | 20 +++-- mbuni/mmsc/mmsrelay.c | 11 ++- mbuni/mmsc/mmsrelay.h | 2 +- mbuni/mmsc/mmssend.c | 13 ++-- 43 files changed, 171 insertions(+), 123 deletions(-) diff --git a/mbuni/ChangeLog b/mbuni/ChangeLog index 7cc6671..9a8821b 100644 --- a/mbuni/ChangeLog +++ b/mbuni/ChangeLog @@ -1,3 +1,7 @@ +2008-07-10 P. A. Bagyenda + * Fixed minimum size of pgsql connection pool + * Fix for shutdown procedure + * Copyright notice updates 2008-07-09 P. A. Bagyenda * Fix for FROM address in MM4_delivery_report.REQ packet 2008-07-07 P. A. Bagyenda diff --git a/mbuni/extras/pgsql-queue/mms_pgsql_queue.c b/mbuni/extras/pgsql-queue/mms_pgsql_queue.c index 7df8389..97903ad 100644 --- a/mbuni/extras/pgsql-queue/mms_pgsql_queue.c +++ b/mbuni/extras/pgsql-queue/mms_pgsql_queue.c @@ -9,7 +9,7 @@ * * Mbuni Queue handler module using PostgreSQL database storage * - * Copyright (C) 2007, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2007-2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * @@ -24,7 +24,8 @@ #define MQF 'q' static List *free_conns; -static int pgq_init_module(Octstr *conninfo) +static int pool_size; +static int pgq_init_module(Octstr *conninfo, int max_threads) { long i, n = 0; @@ -37,14 +38,20 @@ static int pgq_init_module(Octstr *conninfo) if (n <= 0) n = DEFAULT_CONNECTIONS; - + else if (n <= max_threads * 4) { /* must all each thread up to 2 connections, and then some.*/ + + n = max_threads*4 + 1; + + info(0, "pgsql_queue_init: Forced number of DB connections to %d", (int)n); + } free_conns = gwlist_create(); gwlist_add_producer(free_conns); for (i = 0; i %s:%d, %s => %d", file, line, function, (int)c); + if (c) { /* might fail if we are shutting down. */ r = PQexec(c, "BEGIN"); /* start a transaction. */ PQclear(r); - } + } else + error(0, "pg_get_conn: Failed to get a free connection from connection pool! Consider increasing pool size (currently %d)?", + pool_size); return c; } -static void return_conn(PGconn *c) +static void return_conn_real(PGconn *c, const char *function, const char *file, const int line) { PGresult *r; + debug("pg_cp", 0, "pg_release_conn> %s:%d, %s => %d", file, line, function, (int)c); + if (free_conns == NULL) return; /* commit or destroy transaction. */ @@ -825,15 +841,6 @@ static void pgdeliver(List *item_list) /* we're done, exit. */ } -#if 0 -static int cmp_thread_data(char *qfname, struct Qthread_data_t *d) -{ - gw_assert(qfname); - gw_assert(d); - - return (strncmp(d->qf, qfname, sizeof d->qf) == 0); -} -#endif static void pgq_queue_run(char *dir, int (*deliver)(MmsEnvelope *), double sleepsecs, int num_threads, int *rstop) @@ -842,17 +849,21 @@ static void pgq_queue_run(char *dir, List *items_list = gwlist_create(); int i, n; char cmd[512]; + long *th_ids = NULL; gw_assert(num_threads > 0); + info(0, "pgsql_queue: Queue runner on [%s] startup...", dir); if (sleepsecs < MIN_QRUN_INTERVAL) { warning(0, "minimum queue run interval for PG Queue module is %d secs.", MIN_QRUN_INTERVAL); sleepsecs = MIN_QRUN_INTERVAL; } gwlist_add_producer(items_list); + th_ids = gw_malloc(num_threads*sizeof th_ids[0]); + for (i = 0; i * diff --git a/mbuni/mmlib/mms_cfg.h b/mbuni/mmlib/mms_cfg.h index 96346e8..00eca53 100644 --- a/mbuni/mmlib/mms_cfg.h +++ b/mbuni/mmlib/mms_cfg.h @@ -3,7 +3,7 @@ * * config file functions * - * Copyright (C) 2003 - 2006, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmlib/mms_mm7soap.c b/mbuni/mmlib/mms_mm7soap.c index dad368f..f5de576 100644 --- a/mbuni/mmlib/mms_mm7soap.c +++ b/mbuni/mmlib/mms_mm7soap.c @@ -3,7 +3,7 @@ * * MM7/SOAP message encoder/decoder and helper functions * - * Copyright (C) 2003 - 2007, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmlib/mms_mm7soap.h b/mbuni/mmlib/mms_mm7soap.h index f063a08..a087559 100644 --- a/mbuni/mmlib/mms_mm7soap.h +++ b/mbuni/mmlib/mms_mm7soap.h @@ -3,7 +3,7 @@ * * MM7/SOAP message encoder/decoder and helper functions * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmlib/mms_mmbox.c b/mbuni/mmlib/mms_mmbox.c index 187d6e2..13bbcd9 100644 --- a/mbuni/mmlib/mms_mmbox.c +++ b/mbuni/mmlib/mms_mmbox.c @@ -3,7 +3,7 @@ * * Mbuni MMBox implementation * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmlib/mms_mmbox.h b/mbuni/mmlib/mms_mmbox.h index 282a4a3..dfdac26 100644 --- a/mbuni/mmlib/mms_mmbox.h +++ b/mbuni/mmlib/mms_mmbox.h @@ -3,7 +3,7 @@ * * Mbuni MMBox implementation * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmlib/mms_msg.c b/mbuni/mmlib/mms_msg.c index 695693a..060ecb9 100644 --- a/mbuni/mmlib/mms_msg.c +++ b/mbuni/mmlib/mms_msg.c @@ -3,7 +3,7 @@ * * MMS message encoder/decoder and helper functions * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmlib/mms_msg.h b/mbuni/mmlib/mms_msg.h index a470f6d..797b249 100644 --- a/mbuni/mmlib/mms_msg.h +++ b/mbuni/mmlib/mms_msg.h @@ -3,7 +3,7 @@ * * MMS message encoder/decoder and helper functions * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmlib/mms_queue.c b/mbuni/mmlib/mms_queue.c index c005c39..10bbf14 100644 --- a/mbuni/mmlib/mms_queue.c +++ b/mbuni/mmlib/mms_queue.c @@ -3,7 +3,7 @@ * * Queue management functions * - * Copyright (C) 2003 - 2007, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * @@ -48,7 +48,7 @@ struct qfile_t { /* Name of the queue file, pointer to it (locked). D static char sdir[QFNAMEMAX*2+1]; /* top-level storage directory. */ static int inited; -static int mms_init_queue_module(Octstr *storage_dir) +static int mms_init_queue_module(Octstr *storage_dir, int max_threads) { gw_assert(inited==0); gw_assert(storage_dir); @@ -147,7 +147,7 @@ static int _putline(int fd, char *code, char buf[]) return res; } -Octstr *xmake_qf(char realqf[], char subdir[]) +static Octstr *xmake_qf(char realqf[], char subdir[]) { Octstr *res = octstr_format("%s%s", subdir, realqf); /* Make the queue identifier -- convert '/' to '-' */ diff --git a/mbuni/mmlib/mms_queue.h b/mbuni/mmlib/mms_queue.h index 276672c..d43e4b0 100644 --- a/mbuni/mmlib/mms_queue.h +++ b/mbuni/mmlib/mms_queue.h @@ -3,7 +3,7 @@ * * Queue management functions * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * @@ -77,7 +77,7 @@ typedef struct MmsEnvelope { typedef struct MmsQueueHandlerFuncs { /* Initialise queue module. Must be called at least once on each queue dir. */ - int (*mms_init_queue_module)(Octstr *init_data); + int (*mms_init_queue_module)(Octstr *init_data, int max_threads); /* initialise a queue directory. There can be multiple directories, * upperlevel decides what a directory is. diff --git a/mbuni/mmlib/mms_strings.c b/mbuni/mmlib/mms_strings.c index bd525d0..5734dc0 100644 --- a/mbuni/mmlib/mms_strings.c +++ b/mbuni/mmlib/mms_strings.c @@ -3,7 +3,7 @@ * * MMS strings module * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmlib/mms_strings.h b/mbuni/mmlib/mms_strings.h index f369bc1..402e221 100644 --- a/mbuni/mmlib/mms_strings.h +++ b/mbuni/mmlib/mms_strings.h @@ -3,7 +3,7 @@ * * MMS strings module * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmlib/mms_uaprof.c b/mbuni/mmlib/mms_uaprof.c index f31c949..58ea561 100644 --- a/mbuni/mmlib/mms_uaprof.c +++ b/mbuni/mmlib/mms_uaprof.c @@ -3,7 +3,7 @@ * * User-Agent profiles handling, content adaptation. * - * Copyright (C) 2003 - 2007, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmlib/mms_uaprof.h b/mbuni/mmlib/mms_uaprof.h index bfc1312..d5d358a 100644 --- a/mbuni/mmlib/mms_uaprof.h +++ b/mbuni/mmlib/mms_uaprof.h @@ -3,7 +3,7 @@ * * User-Agent profiles handling, content adaptation. * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsbox/mmsbox.c b/mbuni/mmsbox/mmsbox.c index 2b00b29..504c591 100644 --- a/mbuni/mmsbox/mmsbox.c +++ b/mbuni/mmsbox/mmsbox.c @@ -622,7 +622,7 @@ int main(int argc, char *argv[]) qfs->mms_queue_run(octstr_get_cstr(incoming_qdir), mmsbox_service_dispatch, queue_interval, maxthreads, &rstop); - + /* Wait for the sender thread, then quit. */ gwthread_join(qthread); /* Wait for it to die... */ diff --git a/mbuni/mmsbox/mmsbox.h b/mbuni/mmsbox/mmsbox.h index 279b2db..a9137b4 100644 --- a/mbuni/mmsbox/mmsbox.h +++ b/mbuni/mmsbox/mmsbox.h @@ -3,7 +3,7 @@ * * MMSBOX CFG: MMC configuration and misc. functions * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsbox/mmsbox_cfg.c b/mbuni/mmsbox/mmsbox_cfg.c index d662d4b..e43f98f 100644 --- a/mbuni/mmsbox/mmsbox_cfg.c +++ b/mbuni/mmsbox/mmsbox_cfg.c @@ -63,46 +63,6 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func) mms_services = gwlist_create(); mmscs = gwlist_create(); - gdir = mms_cfg_get(grp, octstr_imm("storage-directory")); - - if (gdir == NULL) - gdir = octstr_imm("."); - - if (mkdir(octstr_get_cstr(gdir), - S_IRWXU|S_IRWXG) < 0 && - errno != EEXIST) - panic(0, "Failed to create MMSBox storage directory: %s - %s!", - octstr_get_cstr(gdir), strerror(errno)); - - if ((qfs = _mms_load_module(grp, "queue-manager-module", "qfuncs", NULL)) == NULL) { - 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")); - if (qfs->mms_init_queue_module(s) != 0) - panic(0, "failed to initialise queue module, with data: %s", - octstr_get_cstr(s)); - octstr_destroy(s); - } - - if ((incoming_qdir = qfs->mms_init_queue_dir("mmsbox_incoming", &xx)) == NULL || - xx != 0) - panic(0, "Failed to initialise incoming mmsbox queue directory: %s - %s!", - octstr_get_cstr(incoming_qdir), strerror(errno)); - - if ((outgoing_qdir = qfs->mms_init_queue_dir("mmsbox_outgoing", &xx)) == NULL || - xx != 0) - panic(0, "Failed to initialise outgoing mmsbox queue directory: %s - %s!", - octstr_get_cstr(outgoing_qdir), strerror(errno)); - - /* 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)); - if (mms_cfg_get_int(grp, octstr_imm("maximum-send-attempts"), &mmsbox_maxsendattempts) < 0) mmsbox_maxsendattempts = MAXQTRIES; @@ -124,6 +84,47 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func) } if (queue_interval <= 0) queue_interval = QUEUERUN_INTERVAL; + + gdir = mms_cfg_get(grp, octstr_imm("storage-directory")); + + if (gdir == NULL) + gdir = octstr_imm("."); + + if (mkdir(octstr_get_cstr(gdir), + S_IRWXU|S_IRWXG) < 0 && + errno != EEXIST) + panic(0, "Failed to create MMSBox storage directory: %s - %s!", + octstr_get_cstr(gdir), strerror(errno)); + + if ((qfs = _mms_load_module(grp, "queue-manager-module", "qfuncs", NULL)) == NULL) { + qfs = &default_qfuncs; /* default queue handler. */ + qfs->mms_init_queue_module(gdir, maxthreads); + } else { + Octstr *s = _mms_cfg_getx(grp, octstr_imm("queue-module-init-data")); + if (qfs->mms_init_queue_module(s, maxthreads) != 0) + panic(0, "failed to initialise queue module, with data: %s", + octstr_get_cstr(s)); + octstr_destroy(s); + } + + if ((incoming_qdir = qfs->mms_init_queue_dir("mmsbox_incoming", &xx)) == NULL || + xx != 0) + panic(0, "Failed to initialise incoming mmsbox queue directory: %s - %s!", + octstr_get_cstr(incoming_qdir), strerror(errno)); + + if ((outgoing_qdir = qfs->mms_init_queue_dir("mmsbox_outgoing", &xx)) == NULL || + xx != 0) + panic(0, "Failed to initialise outgoing mmsbox queue directory: %s - %s!", + octstr_get_cstr(outgoing_qdir), strerror(errno)); + + /* XXX still uses old-style file storage. */ + if (qfs != &default_qfuncs) + default_qfuncs.mms_init_queue_module(gdir, maxthreads); + 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)); + unified_prefix = _mms_cfg_getx(grp, octstr_imm("unified-prefix")); @@ -576,3 +577,10 @@ Octstr *get_mmsbox_queue_dir(Octstr *from, List *to, MmscGrp *m, } return 0; } + +void mmsbox_cleanup_mmsc_settings(void) +{ + /* eventually we will destroy the object. For now, we only cleanup queue module. */ + if (qfs) + qfs->mms_cleanup_queue_module(); +} diff --git a/mbuni/mmsbox/mmsbox_cfg.h b/mbuni/mmsbox/mmsbox_cfg.h index 226492f..ff00ff3 100644 --- a/mbuni/mmsbox/mmsbox_cfg.h +++ b/mbuni/mmsbox/mmsbox_cfg.h @@ -3,7 +3,7 @@ * * MMSBOX CFG: MMC configuration and misc. functions * - * Copyright (C) 2003 - 2007, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * @@ -118,4 +118,5 @@ extern MmscGrp *get_handler_mmc(Octstr *id, Octstr *to, Octstr *from); extern Octstr *get_mmsbox_queue_dir(Octstr *from, List *to, MmscGrp *m, Octstr **mmc_id); +extern void mmsbox_cleanup_mmsc_settings(void); #endif diff --git a/mbuni/mmsbox/mmsbox_mmsc.h b/mbuni/mmsbox/mmsbox_mmsc.h index 3c68c36..84b467e 100644 --- a/mbuni/mmsbox/mmsbox_mmsc.h +++ b/mbuni/mmsbox/mmsbox_mmsc.h @@ -3,7 +3,7 @@ * * MMSBOX Custom MMSC types: MMC function definitions * - * Copyright (C) 2003 - 2007, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsbox/mmsbox_mt_filter.c b/mbuni/mmsbox/mmsbox_mt_filter.c index 86c1de4..31a1145 100644 --- a/mbuni/mmsbox/mmsbox_mt_filter.c +++ b/mbuni/mmsbox/mmsbox_mt_filter.c @@ -3,7 +3,7 @@ * * Empty wrapper library * - * Copyright (C) 20078 - , Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsbox/mmsbox_mt_filter.h b/mbuni/mmsbox/mmsbox_mt_filter.h index b0419b8..cea1088 100644 --- a/mbuni/mmsbox/mmsbox_mt_filter.h +++ b/mbuni/mmsbox/mmsbox_mt_filter.h @@ -3,7 +3,7 @@ * * MMSBOX MT MMS filter: Optional filter for MT messages * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsbox/mmsbox_resolve_shell.c b/mbuni/mmsbox/mmsbox_resolve_shell.c index 1c006b4..f5a4684 100644 --- a/mbuni/mmsbox/mmsbox_resolve_shell.c +++ b/mbuni/mmsbox/mmsbox_resolve_shell.c @@ -3,7 +3,7 @@ * * Resolving MSISDNs to local/remote MMSCs - calling shell scripts * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsbox/mmsbox_resolve_shell.h b/mbuni/mmsbox/mmsbox_resolve_shell.h index 552a47a..353dd31 100644 --- a/mbuni/mmsbox/mmsbox_resolve_shell.h +++ b/mbuni/mmsbox/mmsbox_resolve_shell.h @@ -3,7 +3,7 @@ * * Resolving MSISDNs to local/remote MMSCs - interface (shell) * - * Copyright (C) 2003 - 2007, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsc/mms_billing.c b/mbuni/mmsc/mms_billing.c index 625110a..a16208a 100644 --- a/mbuni/mmsc/mms_billing.c +++ b/mbuni/mmsc/mms_billing.c @@ -3,7 +3,7 @@ * * Mbuni sample billing handler module * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsc/mms_billing_shell.h b/mbuni/mmsc/mms_billing_shell.h index fcd596f..88c2143 100644 --- a/mbuni/mmsc/mms_billing_shell.h +++ b/mbuni/mmsc/mms_billing_shell.h @@ -3,7 +3,7 @@ * * Mbuni billing integration interface (shell) * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsc/mms_detokenize.c b/mbuni/mmsc/mms_detokenize.c index 27fdc6e..44660cd 100644 --- a/mbuni/mmsc/mms_detokenize.c +++ b/mbuni/mmsc/mms_detokenize.c @@ -3,7 +3,7 @@ * * Mbuni MSISDN mapper sample * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsc/mms_detokenize.h b/mbuni/mmsc/mms_detokenize.h index 6e5b926..ba6874c 100644 --- a/mbuni/mmsc/mms_detokenize.h +++ b/mbuni/mmsc/mms_detokenize.h @@ -3,7 +3,7 @@ * * Mbuni MSISDN mapper interface * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsc/mms_detokenize_shell.h b/mbuni/mmsc/mms_detokenize_shell.h index fe5a4e7..285c21a 100644 --- a/mbuni/mmsc/mms_detokenize_shell.h +++ b/mbuni/mmsc/mms_detokenize_shell.h @@ -3,7 +3,7 @@ * * Mbuni MSISDN mapper interface (shell) * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsc/mms_resolve.c b/mbuni/mmsc/mms_resolve.c index d6e20c6..673c58e 100644 --- a/mbuni/mmsc/mms_resolve.c +++ b/mbuni/mmsc/mms_resolve.c @@ -3,7 +3,7 @@ * * Resolving MSISDNs to local/remote MMSCs * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsc/mms_resolve.h b/mbuni/mmsc/mms_resolve.h index d222729..0af346a 100644 --- a/mbuni/mmsc/mms_resolve.h +++ b/mbuni/mmsc/mms_resolve.h @@ -3,7 +3,7 @@ * * Resolving MSISDNs to local/remote MMSCs - interface * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsc/mms_resolve_shell.c b/mbuni/mmsc/mms_resolve_shell.c index ef9ccb7..c66ae9e 100644 --- a/mbuni/mmsc/mms_resolve_shell.c +++ b/mbuni/mmsc/mms_resolve_shell.c @@ -3,7 +3,7 @@ * * Resolving MSISDNs to local/remote MMSCs - calling shell scripts * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsc/mms_resolve_shell.h b/mbuni/mmsc/mms_resolve_shell.h index e58528b..11c06d6 100644 --- a/mbuni/mmsc/mms_resolve_shell.h +++ b/mbuni/mmsc/mms_resolve_shell.h @@ -3,7 +3,7 @@ * * Resolving MSISDNs to local/remote MMSCs - interface (shell) * - * Copyright (C) 2003 - 2006, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsc/mmsc_cfg.c b/mbuni/mmsc/mmsc_cfg.c index d7597ca..08d38ed 100644 --- a/mbuni/mmsc/mmsc_cfg.c +++ b/mbuni/mmsc/mmsc_cfg.c @@ -3,7 +3,7 @@ * * MMSC CFG: MMC configuration and misc. functions * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * @@ -94,10 +94,10 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays) if ((m->qfs = _mms_load_module(grp, "queue-manager-module", "qfuncs", NULL)) == NULL) { m->qfs = &default_qfuncs; /* default queue handler. */ - m->qfs->mms_init_queue_module(qdir); + m->qfs->mms_init_queue_module(qdir, m->maxthreads); } else { Octstr *s = _mms_cfg_getx(grp, octstr_imm("queue-module-init-data")); - if (m->qfs->mms_init_queue_module(s) != 0) + if (m->qfs->mms_init_queue_module(s, m->maxthreads) != 0) panic(0, "failed to initialise queue module, with data: %s", octstr_get_cstr(s)); octstr_destroy(s); diff --git a/mbuni/mmsc/mmsc_cfg.h b/mbuni/mmsc/mmsc_cfg.h index e5059fc..a11cdd4 100644 --- a/mbuni/mmsc/mmsc_cfg.h +++ b/mbuni/mmsc/mmsc_cfg.h @@ -3,7 +3,7 @@ * * MMSC CFG: MMC configuration and misc. functions * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsc/mmsfromemail.c b/mbuni/mmsc/mmsfromemail.c index a376044..c0e7930 100644 --- a/mbuni/mmsc/mmsfromemail.c +++ b/mbuni/mmsc/mmsfromemail.c @@ -3,7 +3,7 @@ * * Email2MMS and MM4 (incoming) interface * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsc/mmsglobalsender.c b/mbuni/mmsc/mmsglobalsender.c index 2400a50..a0729db 100644 --- a/mbuni/mmsc/mmsglobalsender.c +++ b/mbuni/mmsc/mmsglobalsender.c @@ -3,7 +3,7 @@ * * MMS Global Queue Runner, routes messages generally. * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * @@ -468,7 +468,7 @@ void mbuni_global_queue_runner(int *rstop) sleep(2); gwlist_remove_producer(cdr_list); /* Stop CDR thread. */ - gwlist_destroy(cdr_list, NULL); /* Destroy it. */ + gwlist_destroy(cdr_list, NULL); return; } diff --git a/mbuni/mmsc/mmsmobilesender.c b/mbuni/mmsc/mmsmobilesender.c index 85a1041..7c3123e 100644 --- a/mbuni/mmsc/mmsmobilesender.c +++ b/mbuni/mmsc/mmsmobilesender.c @@ -4,7 +4,7 @@ * MMS client sender: notifications/reports to clients via WAP Push, * manages out-going messages. * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * @@ -378,6 +378,8 @@ static int sendNotify(MmsEnvelope *e) url = mms_makefetchurl(e->xqfname, e->token, MMS_LOC_MQUEUE, phonenum ? phonenum : to, settings); + info(0, "Preparing to notify client to fetch message at URL: %s", + octstr_get_cstr(url)); transid = mms_maketransid(e->xqfname, settings->host_alias); smsg = mms_notification(msg, e->msize, url, transid, diff --git a/mbuni/mmsc/mmsproxy.c b/mbuni/mmsc/mmsproxy.c index 4340eb1..334ff9b 100644 --- a/mbuni/mmsc/mmsproxy.c +++ b/mbuni/mmsc/mmsproxy.c @@ -3,7 +3,7 @@ * * MMS Proxy interface, implements HTTP interface for client transactions * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * @@ -229,17 +229,21 @@ int main(int argc, char *argv[]) done: debug("proxy", 0, "MM1 Shutting down..."); + + http_close_all_ports(); + debug("proxy", 0, "Port closed"); + + mms_stop_profile_engine(); + + + mms_cleanup_mmsc_settings(settings); + sleep(2); /* Give them time to shut down. */ + if (mm7_thread >= 0) gwthread_join(mm7_thread); debug("proxy", 0, "Closed mm7 thread"); - http_close_all_ports(); - debug("proxy", 0, "Port closed"); - 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(); + info(0, "mmsproxy: Shutdown complete"); return 0; } diff --git a/mbuni/mmsc/mmsrelay.c b/mbuni/mmsc/mmsrelay.c index c870407..737343b 100644 --- a/mbuni/mmsc/mmsrelay.c +++ b/mbuni/mmsc/mmsrelay.c @@ -85,15 +85,20 @@ int main(int argc, char *argv[]) info(0, "Starting Local Queue Runner..."); mbuni_mm1_queue_runner(&rstop); + gwthread_cancel(qthread); /* force it to die if not yet dead. */ - gwthread_join(qthread); /* Wait for it to die... */ - - sleep(2); /* It terminates, so start dying... */ + info(0, "Stopping profile engine..."); mms_stop_profile_engine(); /* Stop profile stuff. */ sleep(2); /* Wait for them to die. */ + info(0, "Final cleanup..."); mms_cleanup_mmsc_settings(settings); + + info(0, "Queue runners shutdown, cleanup commenced..."); + gwthread_join(qthread); /* Wait for it to die... */ + + info(0, "Shutdown complete..."); mms_lib_shutdown(); return 0; }; diff --git a/mbuni/mmsc/mmsrelay.h b/mbuni/mmsc/mmsrelay.h index 3ecb695..12fa72c 100644 --- a/mbuni/mmsc/mmsrelay.h +++ b/mbuni/mmsc/mmsrelay.h @@ -5,7 +5,7 @@ * * MMS Relay, implements message routing * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * diff --git a/mbuni/mmsc/mmssend.c b/mbuni/mmsc/mmssend.c index 474715d..ab29a71 100644 --- a/mbuni/mmsc/mmssend.c +++ b/mbuni/mmsc/mmssend.c @@ -3,7 +3,7 @@ * * MMS send: Inject message into queue for delivery. * - * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com * * Paul Bagyenda * @@ -23,7 +23,7 @@ static Octstr *from; static List *to; static Octstr *data; static int savetommbox; - +static int dlr; static int find_own(int i, int argc, char *argv[]) { @@ -50,7 +50,10 @@ static int find_own(int i, int argc, char *argv[]) return 1; } else return -1; - else + else if (argv[i][1] == 'r') { + dlr = 1; + return 0; + } else return -1; } @@ -160,7 +163,7 @@ int main(int argc, char *argv[]) NULL, NULL, NULL, NULL, h, - 0, + dlr, octstr_get_cstr(settings->global_queuedir), "MM3", settings->host_alias); @@ -174,7 +177,7 @@ int main(int argc, char *argv[]) printf("Queued: %s, mmbox=%s\n", octstr_get_cstr(s), mmbox ? octstr_get_cstr(mmbox) : ""); octstr_destroy(s); - + http_destroy_headers(h); mms_cleanup_mmsc_settings(settings); mms_lib_shutdown();