[asterisk-commits] may: branch may/smpp r404527 - in /team/may/smpp/trunk: ./ addons/res_smpp.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 20 16:30:01 CST 2013


Author: may
Date: Fri Dec 20 16:29:59 2013
New Revision: 404527

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404527
Log:
implement send enquire-link on both smsc and emse
........

Merged revisions 404526 from http://svn.asterisk.org/svn/asterisk/team/may/smpp/branches/10

Modified:
    team/may/smpp/trunk/   (props changed)
    team/may/smpp/trunk/addons/res_smpp.c

Propchange: team/may/smpp/trunk/
------------------------------------------------------------------------------
--- smpp-10-merge (original)
+++ smpp-10-merge Fri Dec 20 16:29:59 2013
@@ -1,1 +1,1 @@
-/team/may/smpp/branches/10:1-402222,403011
+/team/may/smpp/branches/10:1-402222,403011,404526

Propchange: team/may/smpp/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec 20 16:29:59 2013
@@ -1,1 +1,1 @@
-/team/may/smpp/branches/10:400905-401373,401882,402222,403011
+/team/may/smpp/branches/10:400905-401373,401882,402222,403011,404526

Modified: team/may/smpp/trunk/addons/res_smpp.c
URL: http://svnview.digium.com/svn/asterisk/team/may/smpp/trunk/addons/res_smpp.c?view=diff&rev=404527&r1=404526&r2=404527
==============================================================================
--- team/may/smpp/trunk/addons/res_smpp.c (original)
+++ team/may/smpp/trunk/addons/res_smpp.c Fri Dec 20 16:29:59 2013
@@ -119,7 +119,7 @@
 	char system_type[14];
 	int seq;
 	int enquire;
-	time_t lastenq;
+	time_t lastenq, sentenq;
 	char host[MAXHOSTNAMELEN];
 	char connected_host[MAXHOSTNAMELEN];
 	int port;
@@ -464,7 +464,9 @@
 		enq_resp.command_status = ESME_ROK;
 		enq_resp.sequence_number = sequence_number;
 		queue_pdu(smsc, ENQUIRE_LINK_RESP, (void *)&enq_resp);
+		smsc->sentenq = time(NULL);
 	} else if ((uint32_t)enq_resp->command_id == (uint32_t) ENQUIRE_LINK_RESP && enq_resp->command_status == ESME_ROK) {
+		smsc->lastenq = time(NULL);
 	} else {
 		generic_nack_t nack;
 
@@ -816,7 +818,11 @@
 				process_pdu(smsc, unpack);
 			}
 		} else {
-			if (smsc->enquire && time(NULL) - smsc->lastenq >= smsc->enquire) {
+			if (smsc->enquire && time(NULL) - smsc->lastenq >= smsc->enquire * 2) {
+				smsc->stop = 1;
+				pthread_testcancel();
+				continue;
+			} else if (smsc->enquire && time(NULL) - smsc->sentenq >= smsc->enquire) {
 				if (!(smpp_buf = send_enquire_link(smsc))) {
 					close(smsc->socket);
 					smsc->socket = 0;
@@ -824,7 +830,6 @@
 					sleep(12);
 					continue;
 				} 
-				smsc->lastenq = time(NULL);
 			}
 		}
 
@@ -876,7 +881,7 @@
 	int to;
 	int nfds;
 
-	struct smpp_buff *freedbuf;
+	struct smpp_buff *freedbuf, *smpp_buf;
 
 	unsigned char unpack[2048];
 
@@ -939,6 +944,20 @@
 				continue;	// reconnect if receive was unsuccessfull
 			} else {
 				process_pdu(smsc, unpack);
+			}
+		} else {
+			if (smsc->enquire && time(NULL) - smsc->lastenq >= smsc->enquire * 2) {
+				smsc->stop = 1;
+				pthread_testcancel();
+				continue;
+			} else if (smsc->enquire && time(NULL) - smsc->sentenq >= smsc->enquire) {
+				if (!(smpp_buf = send_enquire_link(smsc))) {
+					close(smsc->socket);
+					smsc->socket = 0;
+					pthread_testcancel();
+					sleep(12);
+					continue;
+				} 
 			}
 		}
 
@@ -971,6 +990,7 @@
 
 	if (smsc->socket) {
 		close(smsc->socket);
+		smsc->socket = 0;
 	}
 	ast_sched_context_destroy(sched);
 	if (smppDebug) {




More information about the asterisk-commits mailing list