summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/udp/udp_socket_libevent.cc9
-rw-r--r--net/udp/udp_socket_win.cc9
2 files changed, 15 insertions, 3 deletions
diff --git a/net/udp/udp_socket_libevent.cc b/net/udp/udp_socket_libevent.cc
index ef2bae0..a51567d 100644
--- a/net/udp/udp_socket_libevent.cc
+++ b/net/udp/udp_socket_libevent.cc
@@ -271,7 +271,7 @@ int UDPSocketLibevent::InternalConnect(const IPEndPoint& address) {
// else connect() does the DatagramSocket::DEFAULT_BIND
if (rv < 0) {
- UMA_HISTOGRAM_SPARSE_SLOWLY("Net.UdpSocketRandomBindErrorCode", rv);
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Net.UdpSocketRandomBindErrorCode", -rv);
Close();
return rv;
}
@@ -612,6 +612,13 @@ int UDPSocketLibevent::DoBind(const IPEndPoint& address) {
return OK;
int last_error = errno;
UMA_HISTOGRAM_SPARSE_SLOWLY("Net.UdpSocketBindErrorFromPosix", last_error);
+#if defined(OS_CHROMEOS)
+ if (last_error == EINVAL)
+ return ERR_ADDRESS_IN_USE;
+#elif defined(OS_MACOSX)
+ if (last_error == EADDRNOTAVAIL)
+ return ERR_ADDRESS_IN_USE;
+#endif
return MapSystemError(last_error);
}
diff --git a/net/udp/udp_socket_win.cc b/net/udp/udp_socket_win.cc
index 17fec44..cd4ec4a 100644
--- a/net/udp/udp_socket_win.cc
+++ b/net/udp/udp_socket_win.cc
@@ -339,7 +339,7 @@ int UDPSocketWin::InternalConnect(const IPEndPoint& address) {
// else connect() does the DatagramSocket::DEFAULT_BIND
if (rv < 0) {
- UMA_HISTOGRAM_SPARSE_SLOWLY("Net.UdpSocketRandomBindErrorCode", rv);
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Net.UdpSocketRandomBindErrorCode", -rv);
Close();
return rv;
}
@@ -670,7 +670,12 @@ int UDPSocketWin::DoBind(const IPEndPoint& address) {
int last_error = WSAGetLastError();
UMA_HISTOGRAM_SPARSE_SLOWLY("Net.UdpSocketBindErrorFromWinOS", last_error);
// Map some codes that are special to bind() separately.
- if (last_error == WSAEACCES || last_error == WSAEINVAL)
+ // * WSAEACCES: If a port is already bound to a socket, WSAEACCES may be
+ // returned instead of WSAEADDRINUSE, depending on whether the socket
+ // option SO_REUSEADDR or SO_EXCLUSIVEADDRUSE is set and whether the
+ // conflicting socket is owned by a different user account. See the MSDN
+ // page "Using SO_REUSEADDR and SO_EXCLUSIVEADDRUSE" for the gory details.
+ if (last_error == WSAEACCES || last_error == WSAEADDRNOTAVAIL)
return ERR_ADDRESS_IN_USE;
return MapSystemError(last_error);
}