summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2012-12-05 09:48:44 +0000
committerBenny Prijono <bennylp@teluu.com>2012-12-05 09:48:44 +0000
commitb506f8decdf03624ad88e83f6d03a0fcd0c14cb4 (patch)
tree2316ef4f26d44bb4c6758aea88ec6543fafb9e56 /pjsip
parent58a16c263a03ff494f9befa7c579d28a71abef53 (diff)
Fixed #1597: Handle socket failure in STUN resolution when coming back from iPhone/iOS background mode
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4304 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index b35274ea..58dc441e 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -350,6 +350,25 @@ static pj_status_t create_rtp_rtcp_sock(pjsua_call_media *call_med,
pj_ntohs(pjsua_var.stun_srv.ipv4.sin_port);
status=pjstun_get_mapped_addr2(&pjsua_var.cp.factory, &stun_opt,
2, sock, resolved_addr);
+#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
+ PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0
+ /* Handle EPIPE (Broken Pipe) error, which happens on UDP socket
+ * after app wakes up from suspended state. In this case, simply
+ * just retry.
+ * P.S.: The magic status is PJ_STATUS_FROM_OS(EPIPE)
+ */
+ if (status == 120032) {
+ PJ_LOG(4,(THIS_FILE, "Got EPIPE error, retrying.."));
+ pj_sock_close(sock[0]);
+ sock[0] = PJ_INVALID_SOCKET;
+
+ pj_sock_close(sock[1]);
+ sock[1] = PJ_INVALID_SOCKET;
+
+ continue;
+ }
+ else
+#endif
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "STUN resolve error", status);
goto on_error;