smpp reconnect bugfix

Vibhu Mohindra <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Observation:

If the receiver connection breaks but the transmitter doesn't, then later
even though the receiver manages to reconnect correctly, the transmitter
stops sending SMSs. That is, further submit_sms continue to be queued
instead of being sent.

Reason:

The transmitter io_thread is given enough privileges to update
the status to SMSCCONN_ACTIVE upon successful binding. However the
receiver thread can only make the status SMSCCONN_ACTIVE_RECV. This
means that if the receiver socket breaks then the status is
reduced to SMSCCONN_RECONNECTING. Upon a reconnect it becomes
SMSCCONN_ACTIVE_RECV. Since the transmitter socket never broke it will
not need a reconnect and consequently the status will remain only at
SMSCCONN_ACTIVE_RECV.

The thread receiving SMSs from the smsbox sees that the status is not
SMSCCONN_ACTIVE and so (correctly) continues queueing messages.

Proposed Fix:

Kannel can treat a broken receiving connection exactly the same as
a connected receiving connection where the SMSC has no messages for
it. However it must behave differently when the transmitting connection
is up from when it is down (send messages vs. queue them). This seems
to be why transmitter and transceiver are privileged enough to update
the status to SMSCCONN_ACTIVE, whereas the receiver is not. In the same
spirit I thought it made sense for only the transmitter (or transceiver)
thread to reduce the status to SMSCCONN_RECONNECTING upon a socket snap.

If the receiver socket snaps, the receiver io_thread will go into a
reconnect anyway. However there is no need for it to set the (shared)
status variable to SMSCCONN_RECONNECTING, especially since it is not
itself privileged enough to later restore the status to SMSCCONN_ACTIVE.

Vibhu
smsc_smpp.c.reconnect.patch1 (text/plain, 730 B)
Index: gw/smsc_smpp.c
===================================================================
RCS file: /home/vibhu/cvsroot/gateway/gw/smsc_smpp.c,v
retrieving revision 1.8
diff -u -r1.8 smsc_smpp.c
--- gw/smsc_smpp.c	2002/08/23 14:18:49	1.8
+++ gw/smsc_smpp.c	2002/09/27 15:07:33
@@ -861,7 +861,9 @@
             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; 
+            if (transmitter != 0) {
+                smpp->conn->status = SMSCCONN_RECONNECTING; 
+            }
             continue; 
         }
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

iD8DBQE9lOoHvgqsqbNQjqcRApcIAJ9cDgEHLrUmijDwD8LkHp3RzhHTEwCfRvtt
+5D8BDuw5dN66MxblLnqHlE=
=rI6I
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.