Revision: 15198
Author: vladimir.ralev
Date: Sun Nov 14 18:12:53 2010
Log: Update Issue 1986
Backport for JBCP5
http://code.google.com/p/mobicents/source/detail?r=15198

Modified:
/branches/jbcp/5.x-mead/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/ResponseDispatcher.java /branches/jbcp/5.x-mead/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyBranchImpl.java /branches/jbcp/5.x-mead/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyImpl.java

=======================================
--- /branches/jbcp/5.x-mead/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/ResponseDispatcher.java Wed Oct 27 11:45:01 2010 +++ /branches/jbcp/5.x-mead/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/ResponseDispatcher.java Sun Nov 14 18:12:53 2010
@@ -108,14 +108,7 @@
if(applicationData.getSipServletMessage() instanceof SipServletRequestImpl) { tmpOriginalRequest = (SipServletRequestImpl)applicationData.getSipServletMessage();
                                        }
-                                       final ProxyBranchImpl proxyBranch = 
applicationData.getProxyBranch();
-                                       if(proxyBranch == null && 
sipServletResponse.isRetransmission()) {
-                                               if(logger.isDebugEnabled()) {
- logger.debug("retransmission received for a non proxy application, dropping the response " + response);
-                                               }
-       //                                      
forwardResponseStatefully(sipServletResponse);
-                                               return ;
-                                       }
+ // Retrans drop logic removed from here due to AR case Proxy-B2bua for http://code.google.com/p/mobicents/issues/detail?id=1986
                                } else {
// Issue 1468 : Dropping response in case of forked response and max fork time property stack == 0 to // Guard against exceptions that will arise later if we don't drop it since the support for it is not enabled
@@ -188,7 +181,7 @@
                                if(tmpSession == null) {
                                        sipManager.dumpSipSessions();
                                }
-                       }
+                       }

                        if(tmpSession == null) {
                                if(logger.isDebugEnabled()) {
@@ -196,6 +189,13 @@
                                }
                                return ;
                        } else {
+ // This piece of code move here due to Proxy-B2bua case for http://code.google.com/p/mobicents/issues/detail?id=1986 + if(tmpSession.getProxy() == null && sipServletResponse.isRetransmission()) {
+                                       if(logger.isDebugEnabled()) {
+ logger.debug("retransmission received for a non proxy application, dropping the response " + response);
+                                       }
+                                       return ;
+                               }
                                sipServletResponse.setSipSession(tmpSession);
                        }

=======================================
--- /branches/jbcp/5.x-mead/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyBranchImpl.java Fri Oct 29 01:35:14 2010 +++ /branches/jbcp/5.x-mead/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyBranchImpl.java Sun Nov 14 18:12:53 2010
@@ -498,7 +498,8 @@
                if(status >= 200 && !recursed)
                {

-                       if(outgoingRequest != null && 
outgoingRequest.isInitial()) {
+                       if(proxy.getFinalBranchForSubsequentRequests() == null 
||
+                                       (outgoingRequest != null && 
outgoingRequest.isInitial())) {
                                if(logger.isDebugEnabled())
                                        logger.debug("Handling final response for 
initial request");
                                this.proxy.onFinalResponse(this);
=======================================
--- /branches/jbcp/5.x-mead/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyImpl.java Mon Aug 9 01:15:32 2010 +++ /branches/jbcp/5.x-mead/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyImpl.java Sun Nov 14 18:12:53 2010
@@ -658,46 +658,64 @@
                }

                if(logger.isDebugEnabled())
-                                       logger.debug("Proxy branch has NOT timed 
out");
+                       logger.debug("Proxy branch has NOT timed out");

                //Otherwise proceed with proxying the response
                final SipServletResponseImpl proxiedResponse =
                        ProxyUtils.createProxiedResponse(response, proxyBranch);
-
-
-               if(proxiedResponse.getMessage() == null) {
+
+
+               if(proxiedResponse == null || proxiedResponse.getMessage() == 
null) {
+                       if(logger.isDebugEnabled())
+ logger.debug("Response was dropped because getProxyUtils().createProxiedResponse(response, proxyBranch) returned null");
                        return;// drop out of order message
                }
-
-
-               if(originalRequest != null && proxiedResponse.getRequest() != 
null) {
-                       if(logger.isDebugEnabled())
- logger.debug("Response was dropped because getProxyUtils().createProxiedResponse(response, proxyBranch) returned null");
-                       // non retransmission case
-                       try {
-                               proxiedResponse.send();
-                               if(logger.isDebugEnabled())
- logger.debug("Sending out proxied final response with existing transaction");
-                               proxyBranches.clear();
-                               originalRequest = null;
-                               bestBranch = null;
-                               bestResponse = null;
-                       } catch (Exception e) {
-                               logger.error("A problem occured while proxying the 
final response", e);
-                       }
-               } else {
- // retransmission case, RFC3261 specifies that the retrans should be proxied statelessly
-                       final Message message = proxiedResponse.getMessage();
-                       String transport = JainSipUtils.findTransport(message);
- SipProvider sipProvider = getSipFactoryImpl().getSipNetworkInterfaceManager().findMatchingListeningPoint(
-                                       transport, false).getSipProvider();
-                       try {
-                               if(logger.isDebugEnabled())
- logger.debug("Sending out proxied final response retransmission " + proxiedResponse);
-                               sipProvider.sendResponse((Response)message);
-                       } catch (SipException e) {
- logger.error("A problem occured while proxying the final response retransmission", e);
-                       }
+
+               try {
+
+                       if(originalRequest != null && 
proxiedResponse.getRequest() != null) {
+
+                               // non retransmission case
+                               try {
+ String branch = ((Via)proxiedResponse.getMessage().getHeader(Via.NAME)).getBranch();
+                                       
synchronized(proxyBranch.ongoingTransactions) {
+                                               for(TransactionRequest tr : 
proxyBranch.ongoingTransactions) {
+
+                                                       
if(tr.branchId.equals(branch)) {
+ ((SipServletResponseImpl)proxiedResponse).setTransaction(tr.request.getTransaction()); + ((SipServletResponseImpl)proxiedResponse).setOriginalRequest(tr.request);
+                                                               break;
+                                                       }
+                                               }
+                                       }
+                                       proxiedResponse.send();
+                                       if(logger.isDebugEnabled())
+ logger.debug("Sending out proxied final response with existing transaction");
+                                       proxyBranches.clear();
+                                       originalRequest = null;
+                                       bestBranch = null;
+                                       bestResponse = null;
+                               } catch (Exception e) {
+ logger.error("A problem occured while proxying the final response", e);
+                               }
+                       } else {
+ // retransmission case, RFC3261 specifies that the retrans should be proxied statelessly
+                               final Message message = 
proxiedResponse.getMessage();
+                               String transport = 
JainSipUtils.findTransport(message);
+ SipProvider sipProvider = getSipFactoryImpl().getSipNetworkInterfaceManager().findMatchingListeningPoint(
+                                               transport, 
false).getSipProvider();
+                               try {
+                                       if(logger.isDebugEnabled())
+ logger.debug("Sending out proxied final response retransmission " + proxiedResponse);
+                                       
sipProvider.sendResponse((Response)message);
+                               } catch (SipException e) {
+ logger.error("A problem occured while proxying the final response retransmission", e);
+                               }
+                       }
+               } finally {
+ // This cleanup will eliminate this issues where a retrans leaves unclean branch http://code.google.com/p/mobicents/issues/detail?id=1986
+                       bestBranch = null;
+                       bestResponse = null;
                }
        }

Reply via email to