[PATCH] SMPP Online time

Nisan Bloch <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi

Patch to fix the SMPP online times bug.
conn->connect_time is a share variable amongst threads and is not protected.


This patch works for us. (FYI the large online times one sees is the unix 
timestamp time)

Nisan
smsc_smpp.patch (text/plain, 1.5 KB)
--- ../cvs/gateway/gw/smsc/smsc_smpp.c  Mon Feb 16 22:26:34 2004
+++ gw/smsc/smsc_smpp.c Fri Mar  5 00:17:04 2004
@@ -1197,8 +1197,10 @@
                     smpp->quitting = 1;
             } else {
                 *pending_submits = 0;
+                               mutex_lock(smpp->conn->flow_mutex);
                 smpp->conn->status = SMSCCONN_ACTIVE;
                 smpp->conn->connect_time = time(NULL);
+                               mutex_unlock(smpp->conn->flow_mutex);
                 bb_smscconn_connected(smpp->conn);
             }
             break;
@@ -1215,8 +1217,10 @@
                     smpp->quitting = 1;
             } else {
                 *pending_submits = 0;
+                               mutex_lock(smpp->conn->flow_mutex);
                 smpp->conn->status = SMSCCONN_ACTIVE;
                 smpp->conn->connect_time = time(NULL);
+                               mutex_unlock(smpp->conn->flow_mutex);
                 bb_smscconn_connected(smpp->conn);
             }
             break;
@@ -1234,8 +1238,10 @@
             } else {
                 /* set only resceive status if no transmitt is bind */
                 if (smpp->conn->status != SMSCCONN_ACTIVE) {
+                                       mutex_lock(smpp->conn->flow_mutex);
                     smpp->conn->status = SMSCCONN_ACTIVE_RECV;
                     smpp->conn->connect_time = time(NULL);
+                                       mutex_unlock(smpp->conn->flow_mutex);
                 }
             }
             break;
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.