From d10e7a1e049a481017bd9a7300425d98449b4ab6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Wed, 6 May 2020 11:39:01 -0400
Subject: [PATCH] pjproject: avoid to fail the negotiation when TURN needs a
 retry

This aims to fix the some negotiation failure when:
UserA (TURN ipv4) calls UserB (ipv4 only)

In fact, the first user will take some time to know the userB
addresses to allow on the TURN. So, during this time, the TURN will
give some EPIPE errors. EPIPE is code 32 defined by 120032 in pjsip
(PJ_STATUS_FROM_OS(EPIPE)).

So previous code was a mistake

Change-Id: If38c5d36dc38bfe89e3b2ccfbf1b64c934639adb
---
 contrib/src/pjproject/0001-rfc6544.patch | 8 +++-----
 src/ice_transport.cpp                    | 2 +-
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/contrib/src/pjproject/0001-rfc6544.patch b/contrib/src/pjproject/0001-rfc6544.patch
index 52d20a76d5..44139814d1 100644
--- a/contrib/src/pjproject/0001-rfc6544.patch
+++ b/contrib/src/pjproject/0001-rfc6544.patch
@@ -18,7 +18,6 @@ on behalf of Savoir-faire Linux.
 Rebased for pjsip 2.10 by Peymane Marandi
 <paymon@savoirfairelinux.com>
 on behalf of Savoir-faire Linux.
-
 ---
  pjnath/include/pjnath/ice_session.h     |  173 +++-
  pjnath/include/pjnath/ice_strans.h      |   21 +
@@ -670,7 +669,7 @@ index fff4fad26..e7f8b84eb 100644
      if (status != PJ_SUCCESS && status != PJ_EPENDING) {
  	app_perror("    error: server sending data", status);
 diff --git a/pjnath/src/pjnath/ice_session.c b/pjnath/src/pjnath/ice_session.c
-index 2a4125bc5..d2eae9494 100644
+index 2a4125bc5..85d3234c9 100644
 --- a/pjnath/src/pjnath/ice_session.c
 +++ b/pjnath/src/pjnath/ice_session.c
 @@ -18,6 +18,7 @@
@@ -1247,7 +1246,7 @@ index 2a4125bc5..d2eae9494 100644
 +			status_send_msg);
 +	return;
 +    }
-+    if (status_send_msg == 120033 /* BROKEN PIPE */) {
++    if (status_send_msg == 120032 /* BROKEN PIPE */) {
 +	check->state = PJ_ICE_SESS_CHECK_STATE_NEEDS_RETRY;
 +	check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_NEEDS_RETRY,
 +			status_send_msg);
@@ -4158,5 +4157,4 @@ index 474a8d07c..9257f07a4 100644
  	if (status != PJ_SUCCESS) {
  	    char errmsg[PJ_ERR_MSG_SIZE];
 -- 
-2.25.2
-
+2.25.2
\ No newline at end of file
diff --git a/src/ice_transport.cpp b/src/ice_transport.cpp
index e0d3b88a83..bc3de823c5 100644
--- a/src/ice_transport.cpp
+++ b/src/ice_transport.cpp
@@ -516,7 +516,7 @@ IceTransport::Impl::onComplete(pj_ice_strans* ice_st, pj_ice_strans_op op, pj_st
     }
     else {
         last_errmsg_ = sip_utils::sip_strerror(status);
-        JAMI_ERR("[ice:%p] %s failed: %s", this, opname, last_errmsg_.c_str());
+        JAMI_ERR("[ice:%p] %s %s failed: %s", this, (config_.protocol == PJ_ICE_TP_TCP? "TCP" : "UDP"), opname, last_errmsg_.c_str());
     }
 
     {
-- 
GitLab