Ticket #954: Updated session timer to tolerate 'bad' SE (less than Min-SE specified in request) in 2xx response.

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@2933 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/src/pjsip-ua/sip_timer.c b/pjsip/src/pjsip-ua/sip_timer.c
index bc2b029..51f40c1 100644
--- a/pjsip/src/pjsip-ua/sip_timer.c
+++ b/pjsip/src/pjsip-ua/sip_timer.c
@@ -791,11 +791,25 @@
 	if (se_hdr && 
 	    se_hdr->sess_expires < inv->timer->setting.min_se)
 	{
-	    if (st_code)
-		*st_code = PJSIP_SC_SESSION_TIMER_TOO_SMALL;
-	    pjsip_timer_end_session(inv);
-	    return PJSIP_ERRNO_FROM_SIP_STATUS(
-					    PJSIP_SC_SESSION_TIMER_TOO_SMALL);
+	    /* See ticket #954, instead of returning non-PJ_SUCCESS (which
+	     * may cause disconnecting call/dialog), let's just accept the
+	     * SE and update our local SE, as long as it isn't less than 90s.
+	     */
+	    if (se_hdr->sess_expires >= ABS_MIN_SE) {
+		PJ_LOG(3, (inv->pool->obj_name, 
+			   "Peer responds with bad Session-Expires, %ds, "
+			   "which is less than Min-SE specified in request, "
+			   "%ds. Well, let's just accept and use it.",
+			   se_hdr->sess_expires, inv->timer->setting.min_se));
+
+		inv->timer->setting.sess_expires = se_hdr->sess_expires;
+	    }
+
+	    //if (st_code)
+	    //	*st_code = PJSIP_SC_SESSION_TIMER_TOO_SMALL;
+	    //pjsip_timer_end_session(inv);
+	    //return PJSIP_ERRNO_FROM_SIP_STATUS(
+	    //				    PJSIP_SC_SESSION_TIMER_TOO_SMALL);
 	}
 
 	/* Update SE. Session-Expires in response cannot be lower than Min-SE.