summaryrefslogtreecommitdiff
path: root/pjlib
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2011-01-21 07:15:22 +0000
committerBenny Prijono <bennylp@teluu.com>2011-01-21 07:15:22 +0000
commit655354a2fb0081171025ed3dcd934193c11473c3 (patch)
treeb4735de106f2d3c2d47184508b455c6e4297a433 /pjlib
parentaf600af2db9959eec72c28545df14e43d309099f (diff)
Fixed #1197: WSAECONNRESET errors on Windows 2000 or 2003 may cause UDP transport to stop working
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3408 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib')
-rw-r--r--pjlib/include/pj/config.h11
-rw-r--r--pjlib/src/pj/sock_bsd.c30
2 files changed, 39 insertions, 2 deletions
diff --git a/pjlib/include/pj/config.h b/pjlib/include/pj/config.h
index 6d5e17bc..bf05cbae 100644
--- a/pjlib/include/pj/config.h
+++ b/pjlib/include/pj/config.h
@@ -801,6 +801,17 @@
#endif
+/**
+ * Disable WSAECONNRESET error for UDP sockets on Win32 platforms. See
+ * https://trac.pjsip.org/repos/ticket/1197.
+ *
+ * Default: 1
+ */
+#ifndef PJ_SOCK_DISABLE_WSAECONNRESET
+# define PJ_SOCK_DISABLE_WSAECONNRESET 1
+#endif
+
+
/** @} */
/********************************************************************
diff --git a/pjlib/src/pj/sock_bsd.c b/pjlib/src/pj/sock_bsd.c
index aef2ff8a..47e3fd14 100644
--- a/pjlib/src/pj/sock_bsd.c
+++ b/pjlib/src/pj/sock_bsd.c
@@ -493,8 +493,34 @@ PJ_DEF(pj_status_t) pj_sock_socket(int af,
if (*sock == PJ_INVALID_SOCKET)
return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
- else
- return PJ_SUCCESS;
+
+#if PJ_SOCK_DISABLE_WSAECONNRESET && \
+ (!defined(PJ_WIN32_WINCE) || PJ_WIN32_WINCE==0)
+
+#ifndef SIO_UDP_CONNRESET
+ #define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
+#endif
+
+ /* Disable WSAECONNRESET for UDP.
+ * See https://trac.pjsip.org/repos/ticket/1197
+ */
+ if (type==PJ_SOCK_DGRAM) {
+ DWORD dwBytesReturned = 0;
+ BOOL bNewBehavior = FALSE;
+ DWORD rc;
+
+ rc = WSAIoctl(*sock, SIO_UDP_CONNRESET,
+ &bNewBehavior, sizeof(bNewBehavior),
+ NULL, 0, &dwBytesReturned,
+ NULL, NULL);
+
+ if (rc==SOCKET_ERROR) {
+ // Ignored..
+ }
+ }
+#endif
+
+ return PJ_SUCCESS;
}
#else