[asterisk-commits] may: branch may/smpp r404526 - /team/may/smpp/branches/10/addons/res_smpp.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Dec 20 16:28:10 CST 2013
Author: may
Date: Fri Dec 20 16:28:07 2013
New Revision: 404526
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404526
Log:
implement send enquire-link on both smsc and emse
Modified:
team/may/smpp/branches/10/addons/res_smpp.c
Modified: team/may/smpp/branches/10/addons/res_smpp.c
URL: http://svnview.digium.com/svn/asterisk/team/may/smpp/branches/10/addons/res_smpp.c?view=diff&rev=404526&r1=404525&r2=404526
==============================================================================
--- team/may/smpp/branches/10/addons/res_smpp.c (original)
+++ team/may/smpp/branches/10/addons/res_smpp.c Fri Dec 20 16:28:07 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