1
0
Fork 0

*** empty log message ***

This commit is contained in:
bagyenda 2008-08-29 11:26:27 +00:00
parent b7bd482849
commit 2236d0e9e5
3 changed files with 49 additions and 10 deletions

View File

@ -629,6 +629,8 @@ int main(int argc, char *argv[])
if (sendmms_port.port > 0)
gwthread_join(sthread);
mmsbox_settings_cleanup();
info(0, "Shutdown complete..");
mms_lib_shutdown();

View File

@ -26,14 +26,14 @@
#define WAIT_TIME 0.2
List *sendmms_users = NULL; /* list of SendMmsUser structs */
List *mms_services = NULL; /* list of MMS Services */
List *sendmms_users = NULL; /* list of SendMmsUser structs */
List *mms_services = NULL; /* list of MMS Services */
Octstr *incoming_qdir, *outgoing_qdir, *dlr_dir;
long mmsbox_maxsendattempts, mmsbox_send_back_off, default_msgexpiry;
long maxthreads = 0;
long mmsbox_maxsendattempts, mmsbox_send_back_off, default_msgexpiry;
long maxthreads = 0;
double queue_interval = -1;
Octstr *unified_prefix = NULL;
List *strip_prefixes = NULL;
List *strip_prefixes = NULL;
Octstr *sendmail_cmd = NULL;
Octstr *myhostname = NULL;
@ -45,7 +45,8 @@ Octstr *rfs_settings;
static Dict *mmscs = NULL; /* MMSC's indexed by ID. */
static List *mmsc_del_list = NULL; /* List of items to be deleted. */
struct SendMmsPortInfo sendmms_port;
struct MmsBoxMTfilter *mt_filter = NULL;
@ -73,6 +74,8 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
mms_services = gwlist_create();
mmscs = dict_create(101, NULL);
mmsc_del_list = gwlist_create();
if (mms_cfg_get_int(cfg, grp,
octstr_imm("maximum-send-attempts"), &mmsbox_maxsendattempts) < 0)
mmsbox_maxsendattempts = MAXQTRIES;
@ -546,10 +549,8 @@ void mmsbox_stop_mmsc_conn(Octstr *mmc_id)
mmsbox_stop_mmsc_conn_real(mmc);
while (mmc->use_count > 0) /* wait for use count to reach 0, then delete it. */
gwthread_sleep(WAIT_TIME);
free_mmsc_struct(mmc);
mmc->delete_after = time(NULL) + 5*60; /* delete after 5 minutes. */
gwlist_append(mmsc_del_list, mmc); /* to be deleted later. */
}
void mmsbox_stop_all_mmsc_conn(void)
@ -635,11 +636,45 @@ done:
return res;
}
static void delete_stale_mmsc(int delete_all)
{
MmscGrp *mmc;
int n = gwlist_len(mmsc_del_list);
while (n-- > 0 &&
(mmc = gwlist_extract_first(mmsc_del_list)) != NULL)
if (delete_all ||
(mmc->use_count <= 0 &&
mmc->delete_after <= time(NULL)))
free_mmsc_struct(mmc);
else
gwlist_append(mmsc_del_list, mmc); /* put it back. */
if (delete_all) {
gwlist_destroy(mmsc_del_list, NULL);
mmsc_del_list = NULL;
}
}
void mmsbox_settings_cleanup(void)
{
delete_stale_mmsc(1);
/* More cleanups to follow. */
}
void return_mmsc_conn(MmscGrp *m)
{
if (m)
MMSBOX_MMSC_UNMARK_INUSE(m); /* Vital! */
/* now try and delete as many to-be-deleted mmc as possible */
delete_stale_mmsc(0);
}
/* handle message routing. */
Octstr *get_mmsbox_queue_dir(Octstr *from, List *to, MmscGrp *m,
Octstr **mmc_id)

View File

@ -50,6 +50,7 @@ typedef struct MmscGrp {
int custom_started; /* set to 1 if custom mmc started. */
int use_count; /* use counter. */
time_t delete_after; /* used to control deletion of object -- not ver clean, but... */
} MmscGrp;
#define MMSBOX_MMSC_MARK_INUSE(mmc) do {\
@ -131,6 +132,7 @@ extern Octstr *rfs_settings;
extern int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func);
extern void mmsbox_settings_cleanup(void);
extern MmscGrp *get_handler_mmc(Octstr *id, Octstr *to, Octstr *from);
extern void return_mmsc_conn(MmscGrp *m);