[PATCH] emi2 connection fix
"Angel Fradejas" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Here's a fix against current CVS for the emi2 driver. I've tested it with primary and alternate host setups, dropping connections, and so on, and seems to work fine. Commit please. 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
patch_emi2.diff
(application/octet-stream, 2 KB)
Index: gw/smsc/smsc_emi2.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_emi2.c,v
retrieving revision 1.12
diff -u -r1.12 smsc_emi2.c
--- gw/smsc/smsc_emi2.c 19 Mar 2003 17:40:18 -0000 1.12
+++ gw/smsc/smsc_emi2.c 21 Mar 2003 13:10:29 -0000
@@ -210,11 +210,12 @@
struct emimsg *emimsg;
Connection *server;
Msg *msg;
+ int connect_error = 0;
do_alt_host = octstr_len(privdata->alt_host) != 0 ||
privdata->alt_port != 0;
- alt_host = do_alt_host ? 1 : 0;
+ alt_host = 0;
mutex_lock(conn->flow_mutex);
conn->status = SMSCCONN_RECONNECTING;
@@ -228,11 +229,10 @@
}
/* if there is no alternative host, sleep and try to re-connect */
- if(alt_host == 0) {
+ if ((alt_host == 0) && connect_error) {
error(0, "EMI2[%s]: Couldn't connect to SMS center (retrying in %ld seconds).",
octstr_get_cstr(privdata->name), conn->reconnect_delay);
gwthread_sleep(conn->reconnect_delay);
- continue;
}
if(alt_host != 1) {
@@ -263,6 +263,7 @@
error(0, "EMI2[%s]: opening TCP connection to %s failed",
octstr_get_cstr(privdata->name),
octstr_get_cstr(privdata->host));
+ connect_error = 1;
continue;
}
@@ -279,14 +280,17 @@
error(0, "EMI2[%s]: Server rejected our login",
octstr_get_cstr(privdata->name));
conn_destroy(server);
+ connect_error = 1;
continue;
} else if (result == 0) {
error(0, "EMI2[%s]: Got no reply to login attempt "
"within 30 seconds", octstr_get_cstr(privdata->name));
conn_destroy(server);
+ connect_error = 1;
continue;
} else if (result == -1) { /* Broken connection, already logged */
conn_destroy(server);
+ connect_error = 1;
continue;
}
privdata->last_activity_time = 0; /* to force keepalive after login */