Looks good. As C goes it's fine. I just hope it is useful enough to justify the configuration expansion.

+1

BR,
Nikos
----- Original Message ----- From: "Michael Zervakis" <[email protected]>
To: <[email protected]>
Sent: Wednesday, February 04, 2009 7:51 PM
Subject: Please have a look at this patch adding option to configure SMPPthrottling sleep time


Hi,

   I noticed that SMPP transmitter will sleep for 15 seconds when
receiving a 0x58 (ESME_RTHROTTLED) response declaring that ESME has
exceeded allowed message limits per second. This setting is hardcoded
and I think 15 sec is a long time to wait, so I created this patch to
allow user to configure this parameter as following:
group = smsc
smsc = smpp
.....
throttling-sleep-time = 5

Please have a look at this patch (C is not one of my core competencies).





--------------------------------------------------------------------------------


Index: doc/userguide/userguide.xml
===================================================================
RCS file: /home/cvs/gateway/doc/userguide/userguide.xml,v
retrieving revision 1.344
diff -u -r1.344 userguide.xml
--- doc/userguide/userguide.xml 14 Jan 2009 11:11:46 -0000 1.344
+++ doc/userguide/userguide.xml 4 Feb 2009 17:37:46 -0000
@@ -3190,6 +3190,13 @@
      active session. The default is 30 seconds.
     </entry></row>

+    <row><entry><literal>throttling-sleep-time</literal></entry>
+      <entry><literal>number</literal></entry>
+      <entry valign="bottom">
+      Optional the time the transmitter will sleep after receiving
+      an 0x58 SMPP throttling error. The default is 15 seconds.
+     </entry></row>
+
    <row><entry><literal>max-pending-submits</literal></entry>
      <entry><literal>number</literal></entry>
      <entry valign="bottom">
Index: gw/smsc/smsc_smpp.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_smpp.c,v
retrieving revision 1.112
diff -u -r1.112 smsc_smpp.c
--- gw/smsc/smsc_smpp.c 29 Jan 2009 11:38:28 -0000 1.112
+++ gw/smsc/smsc_smpp.c 4 Feb 2009 17:37:46 -0000
@@ -154,6 +154,7 @@
    int receive_port;
    int quitting;
    long enquire_link_interval;
+    long throttling_sleep_time;
    long max_pending_submits;
    int version;
    int priority;       /* set default priority for messages */
@@ -213,12 +214,12 @@
            Octstr *address_range,
                         int source_addr_ton, int source_addr_npi,
                         int dest_addr_ton, int dest_addr_npi,
- int enquire_link_interval, int max_pending_submits, + int enquire_link_interval, int max_pending_submits,
                         int version, int priority, int validity,
                         Octstr *my_number, int smpp_msg_id_type,
int autodetect_addr, Octstr *alt_charset, Octstr *alt_addr_charset,
                         Octstr *service_type, long connection_timeout,
-                         long wait_ack, int wait_ack_action)
+ long wait_ack, int wait_ack_action, int throttling_sleep_time)
{
    SMPP *smpp;

@@ -245,6 +246,7 @@
    smpp->transmit_port = transmit_port;
    smpp->receive_port = receive_port;
    smpp->enquire_link_interval = enquire_link_interval;
+    smpp->throttling_sleep_time = throttling_sleep_time;
    smpp->max_pending_submits = max_pending_submits;
    smpp->quitting = 0;
    smpp->version = version;
@@ -1771,6 +1773,7 @@
    SMPP_PDU *pdu;
    double timeout;
    time_t last_response, last_cleanup;
+    long throttling_sleep_time;

    io_arg = arg;
    smpp = io_arg->smpp;
@@ -1845,7 +1848,7 @@
                send_enquire_link(smpp, conn, &last_enquire_sent);

                /* Make sure we send even if we read a lot */
- if (transmitter && difftime(time(NULL), smpp->throttling_err_time) > SMPP_THROTTLING_SLEEP_TIME) { + if (transmitter && difftime(time(NULL), smpp->throttling_err_time) > throttling_sleep_time) {
                    smpp->throttling_err_time = 0;
                    send_messages(smpp, conn, &pending_submits);
                }
@@ -1873,7 +1876,7 @@
                last_cleanup = time(NULL);
            }

- if (transmitter && difftime(time(NULL), smpp->throttling_err_time) > SMPP_THROTTLING_SLEEP_TIME) { + if (transmitter && difftime(time(NULL), smpp->throttling_err_time) > throttling_sleep_time) {
                smpp->throttling_err_time = 0;
                send_messages(smpp, conn, &pending_submits);
            }
@@ -2015,6 +2018,7 @@
    int transceiver_mode;
    Octstr *smsc_id;
    long enquire_link_interval;
+    long throttling_sleep_time;
    long max_pending_submits;
    long version;
    long priority;
@@ -2063,6 +2067,9 @@
    if (cfg_get_integer(&max_pending_submits, grp,
                        octstr_imm("max-pending-submits")) == -1)
        max_pending_submits = SMPP_MAX_PENDING_SUBMITS;
+    if (cfg_get_integer(&throttling_sleep_time, grp,
+                        octstr_imm("throttling-sleep-time")) == -1)
+        throttling_sleep_time = SMPP_THROTTLING_SLEEP_TIME;

    /* Check that config is OK */
    ok = 1;
@@ -2162,7 +2169,7 @@
                       dest_addr_npi, enquire_link_interval,
max_pending_submits, version, priority, validity, my_number, smpp_msg_id_type, autodetect_addr, alt_charset, alt_addr_charset, - service_type, connection_timeout, wait_ack, wait_ack_action); + service_type, connection_timeout, wait_ack, wait_ack_action, throttling_sleep_time);

cfg_get_integer(&smpp->bind_addr_ton, grp, octstr_imm("bind-addr-ton")); cfg_get_integer(&smpp->bind_addr_npi, grp, octstr_imm("bind-addr-npi"));
Index: gwlib/cfg.def
===================================================================
RCS file: /home/cvs/gateway/gwlib/cfg.def,v
retrieving revision 1.137
diff -u -r1.137 cfg.def
--- gwlib/cfg.def 14 Jan 2009 11:11:47 -0000 1.137
+++ gwlib/cfg.def 4 Feb 2009 17:37:46 -0000
@@ -385,6 +385,7 @@
    OCTSTR(max-sms-octets)
    OCTSTR(login-prompt)
    OCTSTR(password-prompt)
+    OCTSTR(throttling-sleep-time)
)





Reply via email to