re-org of mmsc code into one executable: mmsc
This commit is contained in:
parent
2236d0e9e5
commit
526ec741fb
|
@ -1,3 +1,5 @@
|
||||||
|
2008-09-01 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||||
|
* Rolled mmsrelay + mmsproxy into one item (for easier online management)
|
||||||
2008-08-29 P. A. Bagyenda <bagyenda@dsmagic.com>
|
2008-08-29 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||||
* Changes to doc for config from DLL
|
* Changes to doc for config from DLL
|
||||||
* Misc. code re-ordering for mmsbox
|
* Misc. code re-ordering for mmsbox
|
||||||
|
|
|
@ -27,23 +27,15 @@ static List *free_conns;
|
||||||
static int pool_size;
|
static int pool_size;
|
||||||
static int pgq_init_module(Octstr *conninfo, int max_threads)
|
static int pgq_init_module(Octstr *conninfo, int max_threads)
|
||||||
{
|
{
|
||||||
long i, n = 0;
|
long i, n;
|
||||||
|
|
||||||
gw_assert(conninfo);
|
gw_assert(conninfo);
|
||||||
i = octstr_search_char(conninfo,':', 0);
|
|
||||||
if (i>0) {
|
n = max_threads + 1;
|
||||||
n = strtoul(octstr_get_cstr(conninfo), NULL, 10);
|
|
||||||
octstr_delete(conninfo, 0, i+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
n = DEFAULT_CONNECTIONS;
|
n = DEFAULT_CONNECTIONS;
|
||||||
else if (n <= max_threads * 4) { /* must all each thread up to 2 connections, and then some.*/
|
info(0, "pgsql_queue_init: Number of DB connections set to %d", (int)n);
|
||||||
|
|
||||||
n = max_threads*4 + 1;
|
|
||||||
|
|
||||||
info(0, "pgsql_queue_init: Forced number of DB connections to %d", (int)n);
|
|
||||||
}
|
|
||||||
free_conns = gwlist_create();
|
free_conns = gwlist_create();
|
||||||
gwlist_add_producer(free_conns);
|
gwlist_add_producer(free_conns);
|
||||||
for (i = 0; i<n;i++) {
|
for (i = 0; i<n;i++) {
|
||||||
|
|
|
@ -76,8 +76,10 @@ typedef struct MmsEnvelope {
|
||||||
} MmsEnvelope;
|
} MmsEnvelope;
|
||||||
|
|
||||||
typedef struct MmsQueueHandlerFuncs {
|
typedef struct MmsQueueHandlerFuncs {
|
||||||
/* Initialise queue module. Must be called at least once on each queue dir. */
|
/* Initialise queue module. Must be called at least once on each queue dir.
|
||||||
int (*mms_init_queue_module)(Octstr *init_data, int max_threads);
|
* max_concurrent is a best guess as to number of concurrent queue requests
|
||||||
|
*/
|
||||||
|
int (*mms_init_queue_module)(Octstr *init_data, int max_concurrent);
|
||||||
|
|
||||||
/* initialise a queue directory. There can be multiple directories,
|
/* initialise a queue directory. There can be multiple directories,
|
||||||
* upperlevel decides what a directory is.
|
* upperlevel decides what a directory is.
|
||||||
|
|
|
@ -120,10 +120,12 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
|
||||||
|
|
||||||
if ((qfs = _mms_load_module(cfg, grp, "queue-manager-module", "qfuncs", NULL)) == NULL) {
|
if ((qfs = _mms_load_module(cfg, grp, "queue-manager-module", "qfuncs", NULL)) == NULL) {
|
||||||
qfs = &default_qfuncs; /* default queue handler. */
|
qfs = &default_qfuncs; /* default queue handler. */
|
||||||
qfs->mms_init_queue_module(gdir, maxthreads);
|
qfs->mms_init_queue_module(gdir, (2 + 1)*maxthreads); /* We expect 2 each for each mmsbox thread,
|
||||||
|
* one each for each bearerbox thread.
|
||||||
|
*/
|
||||||
} else {
|
} else {
|
||||||
Octstr *s = _mms_cfg_getx(cfg, grp, octstr_imm("queue-module-init-data"));
|
Octstr *s = _mms_cfg_getx(cfg, grp, octstr_imm("queue-module-init-data"));
|
||||||
if (qfs->mms_init_queue_module(s, maxthreads) != 0)
|
if (qfs->mms_init_queue_module(s, (2+1)*maxthreads) != 0)
|
||||||
panic(0, "failed to initialise queue module, with data: %s",
|
panic(0, "failed to initialise queue module, with data: %s",
|
||||||
octstr_get_cstr(s));
|
octstr_get_cstr(s));
|
||||||
octstr_destroy(s);
|
octstr_destroy(s);
|
||||||
|
|
|
@ -4,10 +4,9 @@ libmmsc = libmmsc.a
|
||||||
noinst_LIBRARIES = libmmsc.a
|
noinst_LIBRARIES = libmmsc.a
|
||||||
libmmsc_a_SOURCES = mmsc_cfg.c mms_detokenize.c mms_resolve.c mms_billing.c mms_detokenize_shell.c mms_resolve_shell.c mms_billing_shell.c
|
libmmsc_a_SOURCES = mmsc_cfg.c mms_detokenize.c mms_resolve.c mms_billing.c mms_detokenize_shell.c mms_resolve_shell.c mms_billing_shell.c
|
||||||
|
|
||||||
bin_PROGRAMS = mmsrelay mmsproxy mmsfromemail mmssend
|
bin_PROGRAMS = mmsc mmsfromemail mmssend
|
||||||
mmsrelay_SOURCES = mmsglobalsender.c mmsmobilesender.c mmsrelay.c
|
mmsc_SOURCES = mmsc.c mmsglobalsender.c mmsmobilesender.c mmsrelay.c mmsproxy.c
|
||||||
mmsrelay_LDADD = $(libmmsc) $(libmms)
|
mmsc_LDADD = $(libmmsc) $(libmms)
|
||||||
mmsproxy_LDADD = $(libmmsc) $(libmms)
|
|
||||||
mmsfromemail_LDADD = $(libmmsc) $(libmms)
|
mmsfromemail_LDADD = $(libmmsc) $(libmms)
|
||||||
mmssend_LDADD = $(libmmsc) $(libmms)
|
mmssend_LDADD = $(libmmsc) $(libmms)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* Mbuni - Open Source MMS Gateway
|
||||||
|
*
|
||||||
|
* MMSC: Full MMSC startup
|
||||||
|
*
|
||||||
|
* Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com
|
||||||
|
*
|
||||||
|
* Paul Bagyenda <bagyenda@dsmagic.com>
|
||||||
|
*
|
||||||
|
* This program is free software, distributed under the terms of
|
||||||
|
* the GNU General Public License, with a few exceptions granted (see LICENSE)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mmsc.h"
|
||||||
|
#include "mms_uaprof.h"
|
||||||
|
|
||||||
|
static mCfg *cfg;
|
||||||
|
MmscSettings *settings;
|
||||||
|
List *proxyrelays;
|
||||||
|
|
||||||
|
|
||||||
|
static void quit_now(int notused)
|
||||||
|
{
|
||||||
|
stop_mmsrelay();
|
||||||
|
stop_mmsproxy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* manage the SIGHUP signal */
|
||||||
|
static void relog_now(int notused)
|
||||||
|
{
|
||||||
|
warning(0, "SIGHUP received, catching and re-opening logs");
|
||||||
|
log_reopen();
|
||||||
|
alog_reopen();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int cfidx;
|
||||||
|
Octstr *fname;
|
||||||
|
|
||||||
|
long r_thread = 0;
|
||||||
|
|
||||||
|
mms_lib_init();
|
||||||
|
|
||||||
|
srandom(time(NULL));
|
||||||
|
|
||||||
|
cfidx = get_and_set_debugs(argc, argv, NULL);
|
||||||
|
|
||||||
|
if (argv[cfidx] == NULL)
|
||||||
|
fname = octstr_imm("mbuni.conf");
|
||||||
|
else
|
||||||
|
fname = octstr_create(argv[cfidx]);
|
||||||
|
|
||||||
|
cfg = mms_cfg_read(fname);
|
||||||
|
|
||||||
|
if (cfg == NULL)
|
||||||
|
panic(0, "Couldn't read configuration from '%s'.", octstr_get_cstr(fname));
|
||||||
|
|
||||||
|
octstr_destroy(fname);
|
||||||
|
|
||||||
|
info(0, "----------------------------------------");
|
||||||
|
info(0, " " MM_NAME " MMSC version %s starting", MMSC_VERSION);
|
||||||
|
|
||||||
|
|
||||||
|
settings = mms_load_mmsc_settings(cfg,&proxyrelays);
|
||||||
|
|
||||||
|
mms_cfg_destroy(cfg);
|
||||||
|
|
||||||
|
if (!settings)
|
||||||
|
panic(0, "No global MMSC configuration!");
|
||||||
|
|
||||||
|
|
||||||
|
signal(SIGHUP, relog_now);
|
||||||
|
signal(SIGTERM, quit_now);
|
||||||
|
signal(SIGPIPE,SIG_IGN); /* Ignore pipe errors. They kill us sometimes for nothing*/
|
||||||
|
|
||||||
|
|
||||||
|
if ((r_thread = gwthread_create((gwthread_func_t *)mmsrelay, NULL)) < 0)
|
||||||
|
panic(0, "Failed to start MMSC Relay component!");
|
||||||
|
|
||||||
|
if (mmsproxy() < 0)
|
||||||
|
panic(0, "Failed to start MMSC Relay component!");
|
||||||
|
|
||||||
|
/* We are done. Cleanup. */
|
||||||
|
|
||||||
|
info(0, "MMSC shutdown commenced.");
|
||||||
|
|
||||||
|
gwthread_join(r_thread);
|
||||||
|
|
||||||
|
sleep(2); /* Wait for them to die. */
|
||||||
|
info(0, "Final cleanup...");
|
||||||
|
mms_cleanup_mmsc_settings(settings); /* Stop settings stuff and so on. */
|
||||||
|
|
||||||
|
info(0, "Shutdown complete...");
|
||||||
|
mms_lib_shutdown();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,9 +1,7 @@
|
||||||
#ifndef __MMSRELAY_INCLUDED__
|
|
||||||
#define __MMSRELAY_INCLUDED__
|
|
||||||
/*
|
/*
|
||||||
* Mbuni - Open Source MMS Gateway
|
* Mbuni - Open Source MMS Gateway
|
||||||
*
|
*
|
||||||
* MMS Relay, implements message routing
|
* MMSC: Full MMSC startup
|
||||||
*
|
*
|
||||||
* Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com
|
* Copyright (C) 2003 - 2008, Digital Solutions Ltd. - http://www.dsmagic.com
|
||||||
*
|
*
|
||||||
|
@ -12,17 +10,21 @@
|
||||||
* This program is free software, distributed under the terms of
|
* This program is free software, distributed under the terms of
|
||||||
* the GNU General Public License, with a few exceptions granted (see LICENSE)
|
* the GNU General Public License, with a few exceptions granted (see LICENSE)
|
||||||
*/
|
*/
|
||||||
#include <signal.h>
|
#ifndef __MBUNI_MMSC_INCLUDED__
|
||||||
#include <ctype.h>
|
#define __MBUNI_MMSC_INCLUDED__
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "mms_queue.h"
|
|
||||||
#include "mms_uaprof.h"
|
|
||||||
#include "mmsc_cfg.h"
|
#include "mmsc_cfg.h"
|
||||||
#include "mms_mm7soap.h"
|
|
||||||
|
int mmsproxy(void);
|
||||||
|
void stop_mmsproxy(void);
|
||||||
|
|
||||||
|
int mmsrelay(void);
|
||||||
|
int stop_mmsrelay(void);
|
||||||
|
|
||||||
|
|
||||||
extern void mbuni_global_queue_runner(int *stopflag);
|
extern void mbuni_global_queue_runner(int *stopflag);
|
||||||
extern void mbuni_mm1_queue_runner(int *stopflag);
|
extern void mbuni_mm1_queue_runner(int *stopflag);
|
||||||
extern MmscSettings *settings;
|
extern MmscSettings *settings;
|
||||||
extern List *proxyrelays;
|
extern List *proxyrelays;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -94,10 +94,12 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays)
|
||||||
|
|
||||||
if ((m->qfs = _mms_load_module(cfg, grp, "queue-manager-module", "qfuncs", NULL)) == NULL) {
|
if ((m->qfs = _mms_load_module(cfg, grp, "queue-manager-module", "qfuncs", NULL)) == NULL) {
|
||||||
m->qfs = &default_qfuncs; /* default queue handler. */
|
m->qfs = &default_qfuncs; /* default queue handler. */
|
||||||
m->qfs->mms_init_queue_module(qdir, m->maxthreads);
|
m->qfs->mms_init_queue_module(qdir, (2 + 2 + 2)*m->maxthreads); /* We expect 2 max for each mmsrelay component (= 4)
|
||||||
|
* + 2 for mmsproxy (on for mm1proxy, one for mm7proxy
|
||||||
|
*/
|
||||||
} else {
|
} else {
|
||||||
Octstr *s = _mms_cfg_getx(cfg, grp, octstr_imm("queue-module-init-data"));
|
Octstr *s = _mms_cfg_getx(cfg, grp, octstr_imm("queue-module-init-data"));
|
||||||
if (m->qfs->mms_init_queue_module(s, m->maxthreads) != 0)
|
if (m->qfs->mms_init_queue_module(s, (2 + 2 + 2)*m->maxthreads) != 0)
|
||||||
panic(0, "failed to initialise queue module, with data: %s",
|
panic(0, "failed to initialise queue module, with data: %s",
|
||||||
octstr_get_cstr(s));
|
octstr_get_cstr(s));
|
||||||
octstr_destroy(s);
|
octstr_destroy(s);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
* the GNU General Public License, with a few exceptions granted (see LICENSE)
|
* the GNU General Public License, with a few exceptions granted (see LICENSE)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mmsrelay.h"
|
#include "mmsc.h"
|
||||||
|
|
||||||
#define NMAX 256
|
#define NMAX 256
|
||||||
static char mobile_qdir[NMAX];
|
static char mobile_qdir[NMAX];
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
* This program is free software, distributed under the terms of
|
* This program is free software, distributed under the terms of
|
||||||
* the GNU General Public License, with a few exceptions granted (see LICENSE)
|
* the GNU General Public License, with a few exceptions granted (see LICENSE)
|
||||||
*/
|
*/
|
||||||
#include "mmsrelay.h"
|
#include "mmsc.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "mms_uaprof.h"
|
#include "mms_uaprof.h"
|
||||||
#include "mmsc_cfg.h"
|
#include "mmsc_cfg.h"
|
||||||
#include "mms_mm7soap.h"
|
#include "mms_mm7soap.h"
|
||||||
|
#include "mmsc.h"
|
||||||
|
|
||||||
#define MAX_MESSAGE_SIZE 100*1024
|
#define MAX_MESSAGE_SIZE 100*1024
|
||||||
|
|
||||||
|
@ -38,94 +39,20 @@ typedef struct MmsHTTPClientInfo {
|
||||||
MmsVasp *vasp;
|
MmsVasp *vasp;
|
||||||
} MmsHTTPClientInfo;
|
} MmsHTTPClientInfo;
|
||||||
|
|
||||||
static mCfg *cfg;
|
static long mm7_thread = -1;
|
||||||
static List *proxyrelays;
|
|
||||||
static MmscSettings *settings;
|
|
||||||
|
|
||||||
static int rstop = 0;
|
static int rstop = 0;
|
||||||
static void quit_now(int notused)
|
|
||||||
{
|
|
||||||
rstop = 1;
|
|
||||||
if (settings) {
|
|
||||||
http_close_port(settings->port);
|
|
||||||
http_close_port(settings->mm7port);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* manage the SIGHUP signal */
|
|
||||||
static void relog_now(int notused)
|
|
||||||
{
|
|
||||||
warning(0, "SIGHUP received, catching and re-opening logs");
|
|
||||||
log_reopen();
|
|
||||||
alog_reopen();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void free_clientInfo(MmsHTTPClientInfo *h, int freeh);
|
static void free_clientInfo(MmsHTTPClientInfo *h, int freeh);
|
||||||
static void fetchmms_proxy(MmsHTTPClientInfo *h);
|
static void fetchmms_proxy(MmsHTTPClientInfo *h);
|
||||||
static void sendmms_proxy(MmsHTTPClientInfo *h);
|
static void sendmms_proxy(MmsHTTPClientInfo *h);
|
||||||
|
|
||||||
static void mm7proxy(void *unused);
|
static void mm7proxy(void *unused);
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int cfidx;
|
|
||||||
Octstr *fname;
|
|
||||||
|
|
||||||
|
static void mm1proxy(void)
|
||||||
|
{
|
||||||
|
|
||||||
MmsHTTPClientInfo h = {NULL};
|
MmsHTTPClientInfo h = {NULL};
|
||||||
|
|
||||||
long mm7_thread = -1;
|
|
||||||
|
|
||||||
mms_lib_init();
|
|
||||||
srandom(time(NULL));
|
|
||||||
|
|
||||||
cfidx = get_and_set_debugs(argc, argv, NULL);
|
|
||||||
|
|
||||||
if (argv[cfidx] == NULL)
|
|
||||||
fname = octstr_imm("mmsc.conf");
|
|
||||||
else
|
|
||||||
fname = octstr_create(argv[cfidx]);
|
|
||||||
|
|
||||||
cfg = mms_cfg_read(fname);
|
|
||||||
|
|
||||||
if (cfg == NULL)
|
|
||||||
panic(0, "Couldn't read configuration from '%s'.", octstr_get_cstr(fname));
|
|
||||||
|
|
||||||
octstr_destroy(fname);
|
|
||||||
|
|
||||||
info(0, "----------------------------------------");
|
|
||||||
info(0, " " MM_NAME " MMSC Proxy version %s starting", MMSC_VERSION);
|
|
||||||
|
|
||||||
|
|
||||||
/* Load settings. */
|
|
||||||
settings = mms_load_mmsc_settings(cfg, &proxyrelays);
|
|
||||||
|
|
||||||
mms_cfg_destroy(cfg);
|
|
||||||
|
|
||||||
if (!settings)
|
|
||||||
panic(0, "No global MMSC configuration!");
|
|
||||||
|
|
||||||
|
|
||||||
signal(SIGHUP, relog_now);
|
|
||||||
signal(SIGTERM, quit_now);
|
|
||||||
|
|
||||||
/* Start cache engine. */
|
|
||||||
mms_start_profile_engine(octstr_get_cstr(settings->ua_profile_cache_dir));
|
|
||||||
|
|
||||||
/* If we have mm7 port, start thread for it. */
|
|
||||||
/* Now open port and start dispatching requests. */
|
|
||||||
|
|
||||||
if (http_open_port(settings->port, 0) < 0) {
|
|
||||||
error(0, "MMS Proxy: Failed to start http server: %d => %s!",
|
|
||||||
errno, strerror(errno));
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (settings->mm7port > 0 &&
|
|
||||||
http_open_port(settings->mm7port, 0) >= 0)
|
|
||||||
mm7_thread = gwthread_create((gwthread_func_t *)mm7proxy, NULL);
|
|
||||||
else
|
|
||||||
warning(0, "MMS Proxy: MM7 interface not open, port=%ld",
|
|
||||||
settings->mm7port);
|
|
||||||
|
|
||||||
while(rstop == 0 && (h.client = http_accept_request(settings->port,
|
while(rstop == 0 && (h.client = http_accept_request(settings->port,
|
||||||
&h.ip, &h.url, &h.headers,
|
&h.ip, &h.url, &h.headers,
|
||||||
|
@ -227,26 +154,56 @@ int main(int argc, char *argv[])
|
||||||
free_clientInfo(&h, 0);
|
free_clientInfo(&h, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
info(0, "Mmsproxy [mm1]: Shutdown commenced...");
|
||||||
debug("proxy", 0, "MM1 Shutting down...");
|
|
||||||
|
|
||||||
http_close_all_ports();
|
}
|
||||||
debug("proxy", 0, "Port closed");
|
|
||||||
|
|
||||||
mms_stop_profile_engine();
|
int mmsproxy(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
info(0, " " MM_NAME " MMSC Proxy version %s starting", MMSC_VERSION);
|
||||||
|
|
||||||
mms_cleanup_mmsc_settings(settings);
|
mms_start_profile_engine(octstr_get_cstr(settings->ua_profile_cache_dir));
|
||||||
sleep(2); /* Give them time to shut down. */
|
|
||||||
|
|
||||||
if (mm7_thread >= 0)
|
/* If we have mm7 port, start thread for it. */
|
||||||
|
/* Now open port and start dispatching requests. */
|
||||||
|
|
||||||
|
if (http_open_port(settings->port, 0) < 0) {
|
||||||
|
error(0, "MMS Proxy: Failed to start http server: %d => %s!",
|
||||||
|
errno, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings->mm7port > 0 &&
|
||||||
|
http_open_port(settings->mm7port, 0) >= 0)
|
||||||
|
mm7_thread = gwthread_create((gwthread_func_t *)mm7proxy, NULL);
|
||||||
|
else
|
||||||
|
warning(0, "MMS Proxy: MM7 interface not open, port=%ld",
|
||||||
|
settings->mm7port);
|
||||||
|
|
||||||
|
mm1proxy(); /* run mm1 proxy in current thread. */
|
||||||
|
if (mm7_thread >0)
|
||||||
gwthread_join(mm7_thread);
|
gwthread_join(mm7_thread);
|
||||||
info(0, "mmsproxy: Shutdown complete");
|
|
||||||
mms_lib_shutdown();
|
info(0, "Stopping profile engine...");
|
||||||
|
mms_stop_profile_engine(); /* Stop profile stuff. */
|
||||||
|
|
||||||
|
info(0, "Mmsproxy: Shutdown complete.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void stop_mmsproxy(void)
|
||||||
|
{
|
||||||
|
info(0, "Mmsproxy: Shutdown commenced...");
|
||||||
|
rstop = 1;
|
||||||
|
|
||||||
|
http_close_port(settings->port);
|
||||||
|
http_close_port(settings->mm7port);
|
||||||
|
|
||||||
|
info(0, "Mmsproxy: Signalling shutdown complete.");
|
||||||
|
}
|
||||||
|
|
||||||
void fetchmms_proxy(MmsHTTPClientInfo *h)
|
void fetchmms_proxy(MmsHTTPClientInfo *h)
|
||||||
{
|
{
|
||||||
Octstr *dlr_flag = NULL;
|
Octstr *dlr_flag = NULL;
|
||||||
|
@ -1896,8 +1853,7 @@ static void mm7eaif_dispatch(MmsHTTPClientInfo *h)
|
||||||
static void mm7proxy(void *unused)
|
static void mm7proxy(void *unused)
|
||||||
{
|
{
|
||||||
MmsHTTPClientInfo h = {NULL};
|
MmsHTTPClientInfo h = {NULL};
|
||||||
while(rstop == 0 &&
|
while(rstop == 0 && (h.client = http_accept_request(settings->mm7port,
|
||||||
(h.client = http_accept_request(settings->mm7port,
|
|
||||||
&h.ip, &h.url, &h.headers,
|
&h.ip, &h.url, &h.headers,
|
||||||
&h.body, &h.cgivars)) != NULL)
|
&h.body, &h.cgivars)) != NULL)
|
||||||
if (is_allowed_ip(settings->allow_ip, settings->deny_ip, h.ip)) {
|
if (is_allowed_ip(settings->allow_ip, settings->deny_ip, h.ip)) {
|
||||||
|
|
|
@ -10,99 +10,40 @@
|
||||||
* This program is free software, distributed under the terms of
|
* This program is free software, distributed under the terms of
|
||||||
* the GNU General Public License, with a few exceptions granted (see LICENSE)
|
* the GNU General Public License, with a few exceptions granted (see LICENSE)
|
||||||
*/
|
*/
|
||||||
#include "mmsrelay.h"
|
#include "mmsc.h"
|
||||||
|
|
||||||
static mCfg *cfg;
|
|
||||||
MmscSettings *settings;
|
|
||||||
List *proxyrelays;
|
|
||||||
|
|
||||||
|
static long qthread = -1;
|
||||||
|
|
||||||
static int rstop = 0; /* Set to 1 to stop relay. */
|
static int rstop = 0; /* Set to 1 to stop relay. */
|
||||||
static void quit_now(int notused)
|
|
||||||
|
int mmsrelay()
|
||||||
{
|
{
|
||||||
rstop = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* manage the SIGHUP signal */
|
|
||||||
static void relog_now(int notused)
|
|
||||||
{
|
|
||||||
warning(0, "SIGHUP received, catching and re-opening logs");
|
|
||||||
log_reopen();
|
|
||||||
alog_reopen();
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int cfidx;
|
|
||||||
Octstr *fname;
|
|
||||||
|
|
||||||
long qthread = 0;
|
|
||||||
|
|
||||||
mms_lib_init();
|
|
||||||
|
|
||||||
srandom(time(NULL));
|
|
||||||
|
|
||||||
cfidx = get_and_set_debugs(argc, argv, NULL);
|
|
||||||
|
|
||||||
if (argv[cfidx] == NULL)
|
|
||||||
fname = octstr_imm("mbuni.conf");
|
|
||||||
else
|
|
||||||
fname = octstr_create(argv[cfidx]);
|
|
||||||
|
|
||||||
cfg = mms_cfg_read(fname);
|
|
||||||
|
|
||||||
if (cfg == NULL)
|
|
||||||
panic(0, "Couldn't read configuration from '%s'.", octstr_get_cstr(fname));
|
|
||||||
|
|
||||||
octstr_destroy(fname);
|
|
||||||
|
|
||||||
info(0, "----------------------------------------");
|
|
||||||
info(0, " " MM_NAME " MMSC Relay version %s starting", MMSC_VERSION);
|
info(0, " " MM_NAME " MMSC Relay version %s starting", MMSC_VERSION);
|
||||||
|
|
||||||
|
|
||||||
settings = mms_load_mmsc_settings(cfg,&proxyrelays);
|
|
||||||
|
|
||||||
mms_cfg_destroy(cfg);
|
|
||||||
|
|
||||||
if (!settings)
|
|
||||||
panic(0, "No global MMSC configuration!");
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
mms_start_profile_engine(octstr_get_cstr(settings->ua_profile_cache_dir));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
signal(SIGHUP, relog_now);
|
|
||||||
signal(SIGTERM, quit_now);
|
|
||||||
signal(SIGPIPE,SIG_IGN); /* Ignore pipe errors. They kill us sometimes for nothing*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Start global queue runner. */
|
/* Start global queue runner. */
|
||||||
info(0, "Starting Global Queue Runner...");
|
info(0, "Starting Global Queue Runner...");
|
||||||
qthread = gwthread_create((gwthread_func_t *)mbuni_global_queue_runner, &rstop);
|
qthread = gwthread_create((gwthread_func_t *)mbuni_global_queue_runner, &rstop);
|
||||||
|
|
||||||
|
|
||||||
/* Start the local queue runner. */
|
/* Start the local queue runner. */
|
||||||
info(0, "Starting Local Queue Runner...");
|
info(0, "Starting Local Queue Runner...");
|
||||||
mbuni_mm1_queue_runner(&rstop);
|
mbuni_mm1_queue_runner(&rstop);
|
||||||
|
|
||||||
/* gwthread_cancel(qthread); force it to die if not yet dead. */
|
|
||||||
|
|
||||||
/* 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); /* Stop settings stuff and so on. */
|
|
||||||
|
|
||||||
info(0, "Queue runners shutdown, cleanup commenced...");
|
|
||||||
gwthread_join(qthread); /* Wait for it to die... */
|
gwthread_join(qthread); /* Wait for it to die... */
|
||||||
|
info(0, "MMSC Relay MM1 queue runner terminates...");
|
||||||
|
return 0;
|
||||||
|
|
||||||
info(0, "Shutdown complete...");
|
}
|
||||||
mms_lib_shutdown();
|
|
||||||
|
int stop_mmsrelay(void)
|
||||||
|
{
|
||||||
|
rstop = 1;
|
||||||
|
info(0, "Mmsrelay: Queue runners shutdown, cleanup commenced...");
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue