Re: smpp reconnect bugfix
Vibhu Mohindra <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
I just found that my CVS tree hadn't in fact been updated in a while. Sorry about that earlier patch against an old tree. It's a wonder you bothered reading it at all. On Sun, Sep 29, 2002 at 10:49:15AM +0300, Oded Arbel wrote: > maybe a better approach would be to have two status variables ? OK here is my patch against the current CVS version with an additional SMSCCONN_ACTIVE_TRANS state. Given that we start in the SMSCCONN_CONNECTING state and states are changed only upon bind responses or in io_thread(), this is what I've written. (It also reports the status via the admin interface correctly - slightly more accurately than the existing CVS version, since the status now changes to SMSCCONN_RECONNECTING before the first reconnect delay). Vibhu
smscconn.h.diff
(text/plain, 329 B)
--- ../cvs-remote/gateway/gw/smscconn.h Mon Sep 30 05:59:18 2002
+++ smscconn.h Mon Sep 30 06:19:46 2002
@@ -122,6 +122,7 @@
SMSCCONN_CONNECTING,
SMSCCONN_ACTIVE,
SMSCCONN_ACTIVE_RECV,
+ SMSCCONN_ACTIVE_TRANS,
SMSCCONN_RECONNECTING,
SMSCCONN_DISCONNECTED,
SMSCCONN_DEAD /* ready to be cleaned */
smsc_smpp.c.diff
(text/plain, 3.3 KB)
--- smsc/smsc_smpp.c.orig Mon Sep 30 05:33:57 2002
+++ smsc/smsc_smpp.c Mon Sep 30 06:42:57 2002
@@ -848,7 +848,13 @@
pdu->u.bind_transmitter_resp.command_status);
} else {
*pending_submits = 0;
- smpp->conn->status = SMSCCONN_ACTIVE;
+ mutex_lock(smpp->conn->flow_mutex);
+ if (smpp->conn->status == SMSCCONN_CONNECTING || smpp->conn->status == SMSCCONN_RECONNECTING) {
+ smpp->conn->status = SMSCCONN_ACTIVE_TRANS;
+ } else if (smpp->conn->status == SMSCCONN_ACTIVE_RECV) {
+ smpp->conn->status = SMSCCONN_ACTIVE;
+ }
+ mutex_unlock(smpp->conn->flow_mutex);
smpp->conn->connect_time = time(NULL);
bb_smscconn_connected(smpp->conn);
}
@@ -875,11 +881,15 @@
octstr_get_cstr(smpp->conn->id),
pdu->u.bind_receiver_resp.command_status);
} else {
+ mutex_lock(smpp->conn->flow_mutex);
+ if (smpp->conn->status == SMSCCONN_CONNECTING || smpp->conn->status == SMSCCONN_RECONNECTING) {
/* set only resceive status if no transmitt is bind */
- if (smpp->conn->status != SMSCCONN_ACTIVE) {
smpp->conn->status = SMSCCONN_ACTIVE_RECV;
smpp->conn->connect_time = time(NULL);
+ } else if (smpp->conn->status == SMSCCONN_ACTIVE_TRANS) {
+ smpp->conn->status = SMSCCONN_ACTIVE;
}
+ mutex_unlock(smpp->conn->flow_mutex);
}
break;
@@ -956,7 +966,6 @@
error(0, "SMPP[%s]: Couldn't connect to SMS center (retrying in %ld seconds).",
octstr_get_cstr(smpp->conn->id), smpp->reconnect_delay);
gwthread_sleep(smpp->reconnect_delay);
- smpp->conn->status = SMSCCONN_RECONNECTING;
continue;
}
@@ -1003,8 +1012,6 @@
}
if (ret == -1) {
- error(0, "SMPP[%s]: I/O error or other error. Re-connecting.",
- octstr_get_cstr(smpp->conn->id));
break;
}
@@ -1018,6 +1025,27 @@
conn_destroy(conn);
conn = NULL;
+ if (!smpp->quitting) {
+ error(0, "SMPP[%s]: I/O error or other error. Re-connecting.",
+ octstr_get_cstr(smpp->conn->id));
+ mutex_lock(smpp->conn->flow_mutex);
+ if (transmitter == 0) {
+ if (smpp->conn->status == SMSCCONN_ACTIVE) {
+ smpp->conn->status = SMSCCONN_ACTIVE_TRANS;
+ } else if (smpp->conn->status == SMSCCONN_ACTIVE_RECV) {
+ smpp->conn->status = SMSCCONN_RECONNECTING;
+ } //otherwise status remains unchanged
+ } else if (transmitter == 1) {
+ if (smpp->conn->status == SMSCCONN_ACTIVE) {
+ smpp->conn->status = SMSCCONN_ACTIVE_RECV;
+ } else if (smpp->conn->status == SMSCCONN_ACTIVE_TRANS) {
+ smpp->conn->status = SMSCCONN_RECONNECTING;
+ } //otherwise status remains unchanged
+ } else { //transceiver
+ smpp->conn->status = SMSCCONN_RECONNECTING;
+ }
+ mutex_unlock(smpp->conn->flow_mutex);
+ }
}
conn_destroy(conn);
}
bb_smscconn.c.diff
(text/plain, 674 B)
--- ../cvs-remote/gateway/gw/bb_smscconn.c Mon Sep 30 05:59:41 2002
+++ bb_smscconn.c Mon Sep 30 06:17:47 2002
@@ -605,8 +605,13 @@
switch (info.status) {
case SMSCCONN_ACTIVE:
- case SMSCCONN_ACTIVE_RECV:
sprintf(tmp3, "online %lds", info.online);
+ break;
+ case SMSCCONN_ACTIVE_RECV:
+ sprintf(tmp3, "online recv %lds", info.online);
+ break;
+ case SMSCCONN_ACTIVE_TRANS:
+ sprintf(tmp3, "online trans %lds", info.online);
break;
case SMSCCONN_DISCONNECTED:
sprintf(tmp3, "disconnected");
signature.asc
(application/pgp-signature, 232 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9l6nzvgqsqbNQjqcRAsL9AJ0e0Q2vZ3+yzLBlP9Uafrw34QLy9ACeOtxe 17+M+LJ3LdHm/B+e/6Cug/M= =dyzw -----END PGP SIGNATURE-----