Re: smsc_smpp.c - reconnection/enquiry timings
Alan McNatty <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <1021942284.3140.207.camel@euclid> |
Hello, Here's the final patches to include smpp reconnection timings etc to be able to be set via config. As I mentioned before I have added the fields to the smpp structure (see patches below for details). Cheers, Alan On Tue, 2002-05-14 at 12:57, Alan McNatty wrote: > Ok - here's a couple of quick patches which I will be testing but have > posted for comment. I've added the 3 vars into the smpp sturcture and > set to SMPP_ vars if not in config (also required patch for > gwlib/cfg.def which is also required). Comments, etc always appreciated. > Cheers, > Alan
cfg.def-patch
(text/x-patch, 494 B)
Index: cfg.def
===================================================================
RCS file: /home/cvs/gateway/gwlib/cfg.def,v
retrieving revision 1.57
diff -u -r1.57 cfg.def
--- cfg.def 26 Apr 2002 10:49:27 -0000 1.57
+++ cfg.def 21 May 2002 00:43:10 -0000
@@ -208,6 +208,11 @@
OCTSTR(source-addr-npi)
OCTSTR(dest-addr-ton)
OCTSTR(dest-addr-npi)
+ OCTSTR(enquire-link-interval)
+ OCTSTR(max-pending-submits)
+ OCTSTR(reconnect-delay)
OCTSTR(transceiver-mode)
)
smsc_smpp.c-patch
(text/x-patch, 4.2 KB)
Index: smsc_smpp.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc_smpp.c,v
retrieving revision 1.57
diff -u -r1.57 smsc_smpp.c
--- smsc_smpp.c 1 May 2002 18:23:39 -0000 1.57
+++ smsc_smpp.c 21 May 2002 00:42:35 -0000
@@ -41,9 +41,8 @@
#endif
-
/*
- * Some constants.
+ * Some defaults.
*/
#define SMPP_ENQUIRE_LINK_INTERVAL 30.0
@@ -51,7 +50,6 @@
#define SMPP_RECONNECT_DELAY 10.0
-
/***********************************************************************
* Implementation of the actual SMPP protocol: reading and writing
* PDUs in the correct order.
@@ -79,6 +77,9 @@
int transmit_port;
int receive_port;
int quitting;
+ long enquire_link_interval;
+ long max_pending_submits;
+ long reconnect_delay;
SMSCConn *conn;
} SMPP;
@@ -89,6 +90,9 @@
Octstr *address_range, Octstr *our_host,
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 reconnect_delay,
Octstr *my_number)
{
SMPP *smpp;
@@ -114,6 +118,9 @@
smpp->my_number = octstr_duplicate(my_number);
smpp->transmit_port = transmit_port;
smpp->receive_port = receive_port;
+ smpp->enquire_link_interval = enquire_link_interval;
+ smpp->max_pending_submits = max_pending_submits;
+ smpp->reconnect_delay = reconnect_delay;
smpp->quitting = 0;
smpp->conn = conn;
@@ -303,7 +310,7 @@
SMPP_PDU *pdu;
Octstr *os;
- if (date_universal_now() - *last_sent < SMPP_ENQUIRE_LINK_INTERVAL)
+ if (date_universal_now() - *last_sent < smpp->enquire_link_interval)
return;
*last_sent = date_universal_now();
@@ -339,7 +346,7 @@
if (*pending_submits == -1)
return;
- while (*pending_submits < SMPP_MAX_PENDING_SUBMITS) {
+ while (*pending_submits < smpp->max_pending_submits ) {
/* Get next message, quit if none to be sent */
msg = list_extract_first(smpp->msgs_to_send);
if (msg == NULL)
@@ -774,8 +781,8 @@
else
conn = open_receiver(smpp);
if (conn == NULL) {
- error(0, "SMPP: Couldn't connect to SMS center.");
- gwthread_sleep(SMPP_RECONNECT_DELAY);
+ error(0, "SMPP: Couldn't connect to SMS center (retrying in %ld seconds).", smpp->reconnect_delay);
+ gwthread_sleep(smpp->reconnect_delay);
smpp->conn->status = SMSCCONN_RECONNECTING;
continue;
}
@@ -784,7 +791,7 @@
pending_submits = -1;
len = 0;
for (;;) {
- timeout = last_enquire_sent + SMPP_ENQUIRE_LINK_INTERVAL
+ timeout = last_enquire_sent + smpp->enquire_link_interval;
- date_universal_now();
if (smpp->quitting || conn_wait(conn, timeout) == -1)
break;
@@ -902,7 +909,9 @@
SMPP *smpp;
int ok;
int transceiver_mode;
-
+ long enquire_link_interval;
+ long max_pending_submits;
+ long reconnect_delay;
my_number = NULL;
transceiver_mode = 0;
@@ -931,6 +940,15 @@
octstr_destroy(system_id);
}
+ /* Check for timings */
+
+ if (cfg_get_integer(&enquire_link_interval, grp, octstr_imm("enquire-link-interval")) == -1)
+ enquire_link_interval = SMPP_ENQUIRE_LINK_INTERVAL;
+ 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(&reconnect_delay, grp, octstr_imm("reconnect-delay")) == -1)
+ reconnect_delay = SMPP_RECONNECT_DELAY;
+
/* Check that config is OK */
ok = 1;
if (host == NULL) {
@@ -961,7 +979,9 @@
smpp = smpp_create(conn, host, port, receive_port, system_type,
username, password, address_range, our_host,
source_addr_ton, source_addr_npi, dest_addr_ton,
- dest_addr_npi, my_number);
+ dest_addr_npi, enquire_link_interval,
+ max_pending_submits, reconnect_delay,
+ my_number);
conn->data = smpp;
conn->name = octstr_format("SMPP:%S:%d/%d:%S:%S",