Hi list,
please find attached a proposed patchset for a SMSC specific
configuration of the 'sms-combine-concatenated-mo[-timeout]' config
directives.
So you have now the config directives:
group = smsc
...
sms-combine-concatenated-mo = [yes|no]
sms-combine-concatenated-mo-timeout = 1800
available.
If they are NOT set in the 'group = smsc' the values (or defaults) of
the global 'group = core' values are applied.
I revised an initial version with this more simpler approach that simply
adds a 'long timeout' in the ConcatMsg struct directly, being able to
check the SMSC specific timeout value at the time the clean-up is
running. Added the fields to the SMSCconn struct and took care they are
handled as they should.
Please review and comment.
--
Best Regards,
Stipe Tolj
-------------------------------------------------------------------
Düsseldorf, NRW, Germany
Kannel Foundation tolj.org system architecture
http://www.kannel.org/ http://www.tolj.org/
stolj at kannel.org st at tolj.org
-------------------------------------------------------------------
Index: doc/userguide/userguide.xml
===================================================================
--- doc/userguide/userguide.xml (revision 5156)
+++ doc/userguide/userguide.xml (working copy)
@@ -3039,6 +3039,24 @@
</entry>
</row>
+ <row><entry><literal>sms-combine-concatenated-mo</literal></entry>
+ <entry>boolean</entry>
+ <entry valign="bottom">
+ Whether Kannel should attempt to combine concatenated MO SMS
+ prior to passing them over to smsbox for this specific SMSC
connection.
+ (default: yes, if not otherwise defined in core group)
+ </entry>
+ </row>
+
+ <row><entry><literal>sms-combine-concatenated-mo-timeout</literal></entry>
+ <entry>seconds</entry>
+ <entry valign="bottom">
+ How long to wait for all concatenated message parts to arrive before
timeouting
+ for this specific SMSC connection.
+ (default: 1800 seconds, if not otherwise defined in core group)
+ </entry>
+ </row>
+
</tbody>
</tgroup>
</table>
Index: gw/bb_smscconn.c
===================================================================
--- gw/bb_smscconn.c (revision 5159)
+++ gw/bb_smscconn.c (working copy)
@@ -159,9 +159,9 @@
Counter *split_msg_counter;
/* Flag for handling concatenated incoming messages. */
-static volatile sig_atomic_t handle_concatenated_mo;
+volatile sig_atomic_t handle_concatenated_mo;
/* How long to wait for message parts */
-static long concatenated_mo_timeout;
+long concatenated_mo_timeout;
/* Flag for return value of check_concat */
enum {concat_error = -1, concat_complete = 0, concat_pending = 1, concat_none};
@@ -173,7 +173,7 @@
static void concat_handling_init(void);
static void concat_handling_shutdown(void);
static void concat_handling_cleanup(void);
-static int concat_handling_check_and_handle(Msg **msg, Octstr *smscid);
+static int concat_handling_check_and_handle(Msg **msg, Octstr *smscid, long
timeout);
static void concat_handling_clear_old_parts(int force);
/*---------------------------------------------------------------------------
@@ -596,8 +596,9 @@
/* Before routing to some box or re-routing, do concatenation handling
* and replace copy as such.
*/
- if (handle_concatenated_mo && sms->sms.sms_type == mo) {
- ret = concat_handling_check_and_handle(&sms, (conn ? conn->id : NULL));
+ if (conn->handle_concatenated_mo && sms->sms.sms_type == mo) {
+ ret = concat_handling_check_and_handle(&sms, (conn ? conn->id : NULL),
+ conn->concatenated_mo_timeout);
switch(ret) {
case concat_pending:
counter_increase(incoming_sms_counter); /* ?? */
@@ -909,10 +910,12 @@
handle_concatenated_mo = 1; /* default is TRUE. */
if (cfg_get_integer(&concatenated_mo_timeout, grp,
octstr_imm("sms-combine-concatenated-mo-timeout")) == -1)
- concatenated_mo_timeout = 1800;
+ concatenated_mo_timeout = SMS_COMBINE_TIMEOUT;
- if (handle_concatenated_mo)
- concat_handling_init();
+ /* Since we don't know if a SMSC specific value will be set in the
+ * following for loop via smscconn_create() we rather initialize
+ * the structures in any case and potentially don't use them. */
+ concat_handling_init();
/* initialize low level PDUs */
if (smpp_pdu_init(cfg) == -1)
@@ -1989,6 +1992,7 @@
/* array of parts */
Msg **parts;
Octstr *smsc_id; /* name of smsc conn where we received this msgs */
+ long timeout; /* timeout in seconds */
} ConcatMsg;
static Dict *incoming_concat_msgs;
@@ -2070,7 +2074,7 @@
mutex_lock(concat_lock);
x = dict_get(incoming_concat_msgs, key);
octstr_destroy(key);
- if (x == NULL || (!force && difftime(time(NULL), x->trecv) <
concatenated_mo_timeout)) {
+ if (x == NULL || (!force && difftime(time(NULL), x->trecv) <
x->timeout)) {
mutex_unlock(concat_lock);
continue;
}
@@ -2151,7 +2155,7 @@
* - returns concat_pending (and sets *pmsg to NULL) if parts pending
* - returns concat_error if store_save fails
*/
-static int concat_handling_check_and_handle(Msg **pmsg, Octstr *smscid)
+static int concat_handling_check_and_handle(Msg **pmsg, Octstr *smscid, long
timeout)
{
Msg *msg = *pmsg;
int l, iel = 0, refnum, pos, c, part, totalparts, i, sixteenbit;
@@ -2159,9 +2163,6 @@
ConcatMsg *cmsg;
int ret = concat_complete;
- if (!handle_concatenated_mo)
- return concat_none;
-
/* ... module not initialised or there is no UDH or smscid is NULL. */
if (incoming_concat_msgs == NULL || (l = octstr_len(udh)) == 0 || smscid
== NULL)
return concat_none;
@@ -2212,6 +2213,7 @@
cmsg->key = octstr_duplicate(key);
cmsg->ack = ack_success;
cmsg->smsc_id = octstr_duplicate(smscid);
+ cmsg->timeout = timeout;
cmsg->parts = gw_malloc(totalparts * sizeof(*cmsg->parts));
memset(cmsg->parts, 0, cmsg->total_parts * sizeof(*cmsg->parts)); /*
clear it. */
Index: gw/sms.h
===================================================================
--- gw/sms.h (revision 5151)
+++ gw/sms.h (working copy)
@@ -128,6 +128,11 @@
*/
#define MAX_SMS_OCTETS 140
+/*
+ * Default SMS concat re-assembly waiting time in seconds.
+ */
+#define SMS_COMBINE_TIMEOUT 1800
+
/* Encode DCS using sms fields
* mode = 0= encode using 00xxxxxx, 1= encode using 1111xxxx mode
*/
Index: gw/smscconn.c
===================================================================
--- gw/smscconn.c (revision 5150)
+++ gw/smscconn.c (working copy)
@@ -73,6 +73,8 @@
#include "sms.h"
extern Counter *split_msg_counter;
+extern volatile sig_atomic_t handle_concatenated_mo;
+extern long concatenated_mo_timeout;
/*
* Some defaults
@@ -309,6 +311,12 @@
if (cfg_get_bool(&conn->dead_start, grp, octstr_imm("dead-start")) == -1)
conn->dead_start = 0; /* default to connect at start-up time */
+ if (cfg_get_bool((int*)&conn->handle_concatenated_mo, grp,
octstr_imm("sms-combine-concatenated-mo")) == -1)
+ conn->handle_concatenated_mo = handle_concatenated_mo;
+
+ if (cfg_get_integer(&conn->concatenated_mo_timeout, grp,
octstr_imm("sms-combine-concatenated-mo-timeout")) == -1)
+ conn->concatenated_mo_timeout = concatenated_mo_timeout;
+
/* open a smsc-id specific log-file in exlusive mode */
if (conn->log_file)
conn->log_idx = log_open(octstr_get_cstr(conn->log_file),
Index: gw/smscconn_p.h
===================================================================
--- gw/smscconn_p.h (revision 5150)
+++ gw/smscconn_p.h (working copy)
@@ -216,6 +216,10 @@
Load *incoming_dlr_load;
Load *outgoing_dlr_load;
+ /* MO concatenation re-assembly */
+ volatile sig_atomic_t handle_concatenated_mo;
+ long concatenated_mo_timeout;
+
/* XXX: move rest global data from Smsc here
*/
Index: gwlib/cfg.def
===================================================================
--- gwlib/cfg.def (revision 5156)
+++ gwlib/cfg.def (working copy)
@@ -433,6 +433,8 @@
OCTSTR(generic-status-error)
OCTSTR(generic-foreign-id-regex)
OCTSTR(instances)
+ OCTSTR(sms-combine-concatenated-mo)
+ OCTSTR(sms-combine-concatenated-mo-timeout)
)