RE: [REPOST] [PATCH] [RFC] re-connect timming harmonization (SMPP vs. EMI2)
"Angel Fradejas" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, Here is again my patch against current cvs. Angel Fradejas Mediafusión España, S.A. [email protected] www.mediafusion.es Tel. +34 91 252 32 00 Fax +34 91 572 27 08 -----Mensaje original----- De: [email protected] [mailto:[email protected]]En nombre de Stipe Tolj Enviado el: martes 4 de marzo de 2003 14:31 Para: [email protected] Asunto: [RFC] re-connect timming harmonization (SMPP vs. EMI2) Hi list, I'd like to suggest to patch the EMI2 module to use the same re-connect timing config directive as SMPP, SMASI, 'reconnect-delay', instead of the exponential backoff. Main reason is that some SMSC we are connected to leave us some minutes waiting before allowing to login, and the exponential backoff tends to be not very time-near in sense of 'get back to connect ASAP'. Anyway harmonization of the SMSC module behaviour should be a global interest I guess. Any complains or constraints against this?! Stipe [email protected] ------------------------------------------------------------------- Wapme Systems AG Vogelsanger Weg 80 40470 Düsseldorf Tel: +49-211-74845-0 Fax: +49-211-74845-299 E-Mail: [email protected] Internet: http://www.wapme-systems.de ------------------------------------------------------------------- wapme.net - wherever you are
emi2_reconnect.diff
(application/octet-stream, 5.1 KB)
Index: doc/userguide/userguide.xml
===================================================================
RCS file: /home/cvs/gateway/doc/userguide/userguide.xml,v
retrieving revision 1.212
diff -u -r1.212 userguide.xml
--- doc/userguide/userguide.xml 4 Mar 2003 15:16:08 -0000 1.212
+++ doc/userguide/userguide.xml 10 Mar 2003 12:45:38 -0000
@@ -2386,13 +2386,13 @@
use this variable. (optional)
</entry></row>
- <row><entry><literal>retry</literal></entry>
- <entry><literal>boolean</literal></entry>
+ <row><entry><literal>reconnect-delay</literal></entry>
+ <entry><literal>number</literal></entry>
<entry valign="bottom">
- Assuming that kannel is well configured and we had one sucessful
- connection, if retry is true, kannel will always retry the connection
- even if some related error ocur.
- </entry></row>
+ Optional the time between attemps to connect an ESME to an SMSC
+ having failed to connect initating or during a session.
+ The default is 10 seconds.
+ </entry></row>
<row><entry><literal>my-number</literal></entry>
<entry><literal>number</literal></entry>
Index: gw/smsc/smsc_emi2.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_emi2.c,v
retrieving revision 1.11
diff -u -r1.11 smsc_emi2.c
--- gw/smsc/smsc_emi2.c 4 Mar 2003 15:16:09 -0000 1.11
+++ gw/smsc/smsc_emi2.c 10 Mar 2003 12:45:39 -0000
@@ -28,13 +28,14 @@
#include "alt_charsets.h"
#define EMI2_MAX_TRN 100
+#define EMI2_RECONNECT_DELAY 10.0
typedef struct privdata {
Octstr *name;
List *outgoing_queue;
long receiver_thread;
long sender_thread;
- int retry; /* Retry always to connect to smsc */
+ long reconnect_delay;
int shutdown; /* Internal signal to shut down */
int listening_socket; /* File descriptor */
int send_socket;
@@ -216,33 +217,22 @@
privdata->alt_port != 0;
wait = 0;
- alt_host = -1; /* to avoid waiting in first cicle */
+ alt_host = do_alt_host ? 1 : 0;
mutex_lock(conn->flow_mutex);
conn->status = SMSCCONN_RECONNECTING;
mutex_unlock(conn->flow_mutex);
while (!privdata->shutdown) {
- /* Change status only if the first attempt to form a
- * connection fails, as it's possible that the SMSC closed the
- * connection because of idle timeout and a new one will be
- * created quickly. */
- if (wait) {
- while ((msg = list_extract_first(privdata->outgoing_queue))) {
- bb_smscconn_send_failed(conn, msg,
- SMSCCONN_FAILED_TEMPORARILY);
- }
- if(alt_host == 0) {
- info(0, "EMI2[%s]: waiting for %d %s before trying to "
- "connect again", octstr_get_cstr(privdata->name),
- (wait < 60 ? wait : wait/60),
- (wait < 60 ? "seconds" : "minutes"));
- gwthread_sleep(wait);
- wait = wait > (privdata->retry ? 3600 : 600) ?
- (privdata->retry ? 3600 : 600) : wait * 2;
- }
- }
- else
- wait = 15;
+ while ((msg = list_extract_first(privdata->outgoing_queue))) {
+ bb_smscconn_send_failed(conn, msg,
+ SMSCCONN_FAILED_TEMPORARILY);
+ }
+ if(alt_host == 0) {
+ error(0, "EMI2[%s]: Couldn't connect to SMS center (retrying in %ld seconds).",
+ octstr_get_cstr(privdata->name), privdata->reconnect_delay);
+ gwthread_sleep(privdata->reconnect_delay);
+ continue;
+ }
if(alt_host != 1) {
info(0, "EMI2[%s]: connecting to Primary SMSC",
@@ -283,15 +273,11 @@
if (result == -2) {
/* Are SMSCs going to return any temporary errors? If so,
* testing for those error codes should be added here. */
- error(0, "EMI2[%s]: Server rejected our login, giving up",
+ error(0, "EMI2[%s]: Server rejected our login",
octstr_get_cstr(privdata->name));
conn_destroy(server);
- if(! privdata->retry) {
- conn->why_killed = SMSCCONN_KILLED_WRONG_PASSWORD;
- return NULL;
- } else
- continue;
- }
+ continue;
+ }
else if (result == 0) {
error(0, "EMI2[%s]: Got no reply to login attempt "
"within 30 s", octstr_get_cstr(privdata->name));
@@ -1631,9 +1617,9 @@
privdata->npid = cfg_get(cfg, octstr_imm("notification-pid"));
privdata->nadc = cfg_get(cfg, octstr_imm("notification-addr"));
- cfg_get_bool(&privdata->retry, cfg, octstr_imm("retry"));
- if(privdata->retry < 0)
- privdata->retry = 0;
+ if (cfg_get_integer(&privdata->reconnect_delay, cfg,
+ octstr_imm("reconnect-delay")) == -1)
+ privdata->reconnect_delay = EMI2_RECONNECT_DELAY;
if ( (privdata->username == NULL && privdata->my_number == NULL)
|| cfg_get_integer(&keepalive, cfg, octstr_imm("keepalive")) < 0)
Index: gwlib/cfg.def
===================================================================
RCS file: /home/cvs/gateway/gwlib/cfg.def,v
retrieving revision 1.83
diff -u -r1.83 cfg.def
--- gwlib/cfg.def 4 Mar 2003 15:16:09 -0000 1.83
+++ gwlib/cfg.def 10 Mar 2003 12:45:39 -0000
@@ -227,7 +227,6 @@
OCTSTR(appname)
OCTSTR(ussdc)
OCTSTR(session-length)
- OCTSTR(retry)
OCTSTR(my-number)
OCTSTR(sms-center)
OCTSTR(source-addr-ton)