--- 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)
 )
 
 
