use of javax.sip.TransactionState in project XobotOS by xamarin.
the class SIPTransactionStack method auditTransactions.
/**
* Audits SIP transactions for leaks
*
* @return Audit report, null if no transaction leaks were found
*/
private String auditTransactions(ConcurrentHashMap transactionsMap, long a_nLeakedTransactionTimer) {
String auditReport = " Leaked transactions:\n";
int leakedTransactions = 0;
long currentTime = System.currentTimeMillis();
// Make a shallow copy of the transaction list.
// This copy will remain intact as leaked transactions are removed by
// the stack.
LinkedList transactionsList = new LinkedList(transactionsMap.values());
// Iterate through our copy
Iterator it = transactionsList.iterator();
while (it.hasNext()) {
SIPTransaction sipTransaction = (SIPTransaction) it.next();
if (sipTransaction != null) {
if (sipTransaction.auditTag == 0) {
// First time we see this transaction. Mark it as audited.
sipTransaction.auditTag = currentTime;
} else {
// up.
if (currentTime - sipTransaction.auditTag >= a_nLeakedTransactionTimer) {
// Leaked transaction found
leakedTransactions++;
// Generate some report
TransactionState transactionState = sipTransaction.getState();
SIPRequest origRequest = sipTransaction.getOriginalRequest();
String origRequestMethod = (origRequest != null ? origRequest.getMethod() : null);
String transactionReport = sipTransaction.getClass().getName() + ", state: " + (transactionState != null ? transactionState.toString() : "null") + ", OR: " + (origRequestMethod != null ? origRequestMethod : "null");
auditReport += " " + transactionReport + "\n";
// Kill it
removeTransaction(sipTransaction);
if (isLoggingEnabled())
stackLogger.logDebug("auditTransactions: leaked " + transactionReport);
}
}
}
}
// Return final report
if (leakedTransactions > 0) {
auditReport += " Total: " + Integer.toString(leakedTransactions) + " leaked transactions detected and removed.\n";
} else {
auditReport = null;
}
return auditReport;
}
use of javax.sip.TransactionState in project XobotOS by xamarin.
the class SIPServerTransaction method map.
/**
* Send out a trying response (only happens when the transaction is mapped). Otherwise the
* transaction is not known to the stack.
*/
protected void map() {
// note that TRYING is a pseudo-state for invite transactions
TransactionState realState = getRealState();
if (realState == null || realState == TransactionState.TRYING) {
// null check added as the stack may be stopped.
if (isInviteTransaction() && !this.isMapped && sipStack.getTimer() != null) {
this.isMapped = true;
// Schedule a timer to fire in 200 ms if the
// TU did not send a trying in that time.
sipStack.getTimer().schedule(new SendTrying(), 200);
} else {
isMapped = true;
}
}
// Pull it out of the pending transactions list.
sipStack.removePendingTransaction(this);
}
use of javax.sip.TransactionState in project XobotOS by xamarin.
the class SIPClientTransaction method fireRetransmissionTimer.
/**
* Called by the transaction stack when a retransmission timer fires.
*/
protected void fireRetransmissionTimer() {
try {
// Resend the last request sent
if (this.getState() == null || !this.isMapped)
return;
boolean inv = isInviteTransaction();
TransactionState s = this.getState();
// Bug-fix for non-INVITE transactions not retransmitted when 1xx response received
if ((inv && TransactionState.CALLING == s) || (!inv && (TransactionState.TRYING == s || TransactionState.PROCEEDING == s))) {
if (lastRequest != null) {
if (sipStack.generateTimeStampHeader && lastRequest.getHeader(TimeStampHeader.NAME) != null) {
long milisec = System.currentTimeMillis();
TimeStamp timeStamp = new TimeStamp();
try {
timeStamp.setTimeStamp(milisec);
} catch (InvalidArgumentException ex) {
InternalErrorHandler.handleException(ex);
}
lastRequest.setHeader(timeStamp);
}
super.sendMessage(lastRequest);
if (this.notifyOnRetransmit) {
TimeoutEvent txTimeout = new TimeoutEvent(this.getSipProvider(), this, Timeout.RETRANSMIT);
this.getSipProvider().handleEvent(txTimeout, this);
}
if (this.timeoutIfStillInCallingState && this.getState() == TransactionState.CALLING) {
this.callingStateTimeoutCount--;
if (callingStateTimeoutCount == 0) {
TimeoutEvent timeoutEvent = new TimeoutEvent(this.getSipProvider(), this, Timeout.RETRANSMIT);
this.getSipProvider().handleEvent(timeoutEvent, this);
this.timeoutIfStillInCallingState = false;
}
}
}
}
} catch (IOException e) {
this.raiseIOExceptionEvent();
raiseErrorEvent(SIPTransactionErrorEvent.TRANSPORT_ERROR);
}
}
Aggregations