RE: [PATCH] Kannel resending old unsuccessful messges after a box restart.BUG?
"Oded Arbel" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Why am I keep forgetting to attach the patch files ? beats me. -- Oded Arbel m-Wise mobile solutions [email protected] +972-9-9581711 (116) +972-67-340014 ::.. "...It's camouflage, and stylish too! Yes, tigers look the best, it's true!" -- Calvin and Hobbes > -----Original Message----- > From: Oded Arbel > Sent: Sunday, August 25, 2002 7:58 PM > To: Oded Arbel; Damjan; [email protected] > Subject: [PATCH] Kannel resending old unsuccessful messges > after a box restart.BUG? > > > Hi list. > > Attached is a patch to introduce configurable throttling > delay with backoff. the patch adds another configuration > option: 'throttling-delay' that is used as the base delay for > a simple backoff mechanism that will simply double the last > sleep time and sleep again, if it after sleeping and sending > it received another throttling error. > > Warning - this patch is _not_ tested ! it simply compiles. I > would like to have comments on the code, the solution methods > and the new configuration option name. testing would be nice > too :-) I'll try to find time to upload the changes to a test > platform tommorow. > > -- > Oded Arbel > m-Wise mobile solutions > [email protected] > > +972-9-9581711 (116) > +972-67-340014 > > ::.. > In shallow waters, shrimps make fools of dragons. > -- Chinese Proverb > > > > -----Original Message----- > > From: Oded Arbel > > > > >>Current CVS version does handle 'Throttling Error' properly > > by stoping > > >>to send messages for a predetrmind time - 15 seconds currently. > > >> > > >> > > > > > >Thats too much, I'm using my own scripts with a perl SMPP driver, > > >usually I can send some 4 messages as fast as I can send them, > > >and then I get the "Throttling Error", I then wait some 0.8 > > >seconds and then continue to send. Actually it depends of the > > >settings your SMPP provider has set-up for your connection. > > > > > > > > Currently it's set as a compile time option, which you can > > change - 15 > > seconds is what O2 required of us in their credentials tests. but I > > agree it's not the best course. Here at m-Wise we usually do > > that, since > > most time we don't think about other people's needs as much as we > > should, as Andreas Fink pointed out, and we usually put in > > new features > > with a compile time option, thinking - "If we ever find a > > provider that > > requires a different setting - we'll add a configuration > > option, as it's > > simple enough". I assure you that it is pure laziness and not > > because we > > are bad people :-) > > > > If the developers have no objections, I'll implement a run-time > > configuration option which will default to the compile time option > > (currently 15 seconds), first thing sunday morn. alternativly > > - do you > > think its possible/needed/interesting implementing some kind of > > exponential backoff mechanism that will start at a small delay and > > increase it as long as it gets consecutive 'Throttling Errors' ? > >
smsc_smpp.patch
(application/octet-stream, 4.4 KB)
--- gw/smsc/smsc_smpp.c 2002-08-25 20:52:36.000000000 +0300
+++ gw/smsc/smsc_smpp.c 2002-08-25 20:52:01.000000000 +0300
@@ -51,7 +51,7 @@
#define SMPP_RECONNECT_DELAY 10.0
#define SMPP_DEFAULT_VERSION 0x34
#define SMPP_DEFAULT_PRIORITY 0
-#define SMPP_THROTTLING_SLEEP_TIME 15
+#define SMPP_THROTTLING_SLEEP_TIME 0.5
/*
* Some SMPP error messages we come across
@@ -59,7 +59,9 @@
enum {
SMPP_ESME_RMSGQFUL = 0x00000014,
- SMPP_ESME_RTHROTTLED = 0x00000058
+ SMPP_ESME_RTHROTTLED = 0x00000058,
+ SMPP_ESME_RINVSCHED = 0x00000061,
+ SMPP_ESME_RINVEXPIRY = 0x00000062
} SMPP_ERROR_MESSAGES;
@@ -97,6 +99,8 @@
int version;
int priority; /* set default priority for messages */
time_t throttling_err_time;
+ double last_throttling_sleep;
+ double throttling_delay_base;
SMSCConn *conn;
} SMPP;
@@ -109,6 +113,7 @@
int dest_addr_ton, int dest_addr_npi,
int alt_dcs, int enquire_link_interval,
int max_pending_submits, int reconnect_delay,
+ double throttling_delay_base,
int version, int priority, Octstr *my_number)
{
SMPP *smpp;
@@ -143,6 +148,8 @@
smpp->priority = priority;
smpp->conn = conn;
smpp->throttling_err_time = 0;
+ smpp->last_throttling_sleep = 0;
+ smpp->throttling_delay_base = throttling_delay_base;
return smpp;
}
@@ -734,10 +741,14 @@
* check to see if we got a "throttling error", in which case we'll just
* sleep for a while
*/
- if (pdu->u.submit_sm.command_status == SMPP_ESME_RTHROTTLED)
+ if (pdu->u.submit_sm.command_status == SMPP_ESME_RTHROTTLED) {
time(&(smpp->throttling_err_time));
- else
+ smpp->last_throttling_sleep = smpp->last_throttling_sleep ?
+ (smpp->last_throttling_sleep * 2) : smpp->throttling_delay_base;
+ } else {
smpp->throttling_err_time = 0;
+ smpp->last_throttling_sleep = 0;
+ }
/* gen DLR_SMSC_FAIL */
if (reason == SMSCCONN_FAILED_REJECTED &&
@@ -975,7 +986,7 @@
/* Make sure we send even if we read a lot */
if (transmitter &&
(!smpp->throttling_err_time ||
- ((time(NULL) - smpp->throttling_err_time) > SMPP_THROTTLING_SLEEP_TIME
+ ((time(NULL) - smpp->throttling_err_time) > smpp->last_throttling_sleep
&& !(smpp->throttling_err_time = 0)))
)
send_messages(smpp, conn, &pending_submits);
@@ -989,7 +1000,7 @@
if (transmitter &&
(!smpp->throttling_err_time ||
- ((time(NULL) - smpp->throttling_err_time) > SMPP_THROTTLING_SLEEP_TIME
+ ((time(NULL) - smpp->throttling_err_time) > smpp->last_throttling_sleep
&& !(smpp->throttling_err_time = 0)))
)
send_messages(smpp, conn, &pending_submits);
@@ -1089,6 +1100,7 @@
long reconnect_delay;
long version;
long priority;
+ long throttling_delay_base;
my_number = NULL;
@@ -1133,6 +1145,9 @@
if (cfg_get_integer(&reconnect_delay, grp,
octstr_imm("reconnect-delay")) == -1)
reconnect_delay = SMPP_RECONNECT_DELAY;
+ if (cfg_get_integer(&throttling_delay_base, grp,
+ octstr_imm("throttlling-delay")) == -1)
+ throttling_delay_base = SMPP_THROTTLING_SLEEP_TIME;
/* Check that config is OK */
ok = 1;
@@ -1186,6 +1201,7 @@
source_addr_ton, source_addr_npi, dest_addr_ton,
dest_addr_npi, alt_dcs, enquire_link_interval,
max_pending_submits, reconnect_delay,
+ throttling_delay_base,
version, priority, my_number);
conn->data = smpp;
--- gwlib/cfg.def 2002-08-25 20:52:36.000000000 +0300
+++ gwlib/cfg.def 2002-08-25 20:51:09.000000000 +0300
@@ -219,6 +219,7 @@
OCTSTR(priority)
OCTSTR(notification-pid)
OCTSTR(notification-addr)
+ OCTSTR(throttlling-delay)
)