Avoids send error message to transaction that has already sent a response.

This commit is contained in:
seb 2011-09-22 15:33:51 +00:00
parent 6d912a0fa1
commit 547c568d9d
2 changed files with 19 additions and 1 deletions

View File

@ -53,6 +53,11 @@ public class StunException extends Exception
*/
public static final int NETWORK_ERROR = 4;
/**
* Thrown when trying to send responses through a transaction that have
* already sent a response.
*/
public static final int TRANSACTION_ALREADY_ANSWERED = 5;
/**
* Identifies the exception.

View File

@ -489,7 +489,7 @@ public class StunStack
}
else if( sTran.isRetransmitting())
{
throw new StunException(StunException.TRANSACTION_DOES_NOT_EXIST,
throw new StunException(StunException.TRANSACTION_ALREADY_ANSWERED,
"The transaction specified in the response "
+ "(tid="+ tid.toString() +") "
+ "has already seen a previous response. "
@ -690,6 +690,19 @@ public class StunStack
Response error;
logger.log(Level.INFO, "Received an invalid request.", t);
Throwable cause = t.getCause();
if(((t instanceof StunException) &&
((StunException)t).getID() ==
StunException.TRANSACTION_ALREADY_ANSWERED) ||
(cause != null && (cause instanceof StunException) &&
((StunException)cause).getID() ==
StunException.TRANSACTION_ALREADY_ANSWERED))
{
// do not try to send an error response since we will
// get another TRANSACTION_ALREADY_ANSWERED
return;
}
if(t instanceof IllegalArgumentException)
{