Bug 899757: Distinguish PR_ADDRESS_NOT_SUPPORTED_ERROR from other network failures. r=mayhemer
authorJim Blandy <jimb@mozilla.com>
Fri, 06 Sep 2013 08:06:22 -0700
changeset 158858 d9d740e7a3a01ec7096ebe77ba349b1caf29986b
parent 158857 5eb5741ec1ccfe059533cb657fc673641eab301d
child 158859 645e832547c09f40eee4c0a535916d2ec49c60e6
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs899757
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 899757: Distinguish PR_ADDRESS_NOT_SUPPORTED_ERROR from other network failures. r=mayhemer I broke out this this change on its own, because it seemed to require some care: PR_ADDRESS_NOT_SUPPORTED_ERROR used to be lumped in with several other NSPR error codes and reported as NS_ERROR_CONNECTION_REFUSED; and a dumb grep shows that the NS_ERROR_ is widely checked for. Introducing the distinction might require the new NS_ERROR_SOCKET_ADDRESS_NOT_SUPPORTED value to be checked for everywhere that currently checks for NS_ERROR_CONNECTION_REFUSED. But that seems unlikely to be necessary: first of all, it shouldn't really be possible, via the XPCOM interface, to force this error path to occur at present: the components' implementations are in complete control over which socket address types get used. I also did a Try push with a call to NS_ABORT if a PR_ADDRESS_NOT_SUPPORTED_ERROR ever flows through ErrorAccordingToNSPR; there were no crashes. But if that's so, then why introduce the new error code at all? A later patch adds support for Unix-domain sockets, a type of socket address which is *not* supported on non-Unix systems. In that case, a distinct error code will help people diagnose problems quickly.
js/xpconnect/src/xpc.msg
netwerk/base/src/nsSocketTransport2.cpp
xpcom/base/ErrorList.h
--- a/js/xpconnect/src/xpc.msg
+++ b/js/xpconnect/src/xpc.msg
@@ -161,16 +161,17 @@ XPC_MSG_DEF(NS_ERROR_FTP_CWD            
 XPC_MSG_DEF(NS_ERROR_FTP_PASV                       , "FTP error while changing to passive mode")
 XPC_MSG_DEF(NS_ERROR_FTP_PWD                        , "FTP error while retrieving current directory")
 XPC_MSG_DEF(NS_ERROR_FTP_LIST                       , "FTP error while retrieving a directory listing")
 XPC_MSG_DEF(NS_ERROR_UNKNOWN_HOST                   , "The lookup of the hostname failed")
 XPC_MSG_DEF(NS_ERROR_DNS_LOOKUP_QUEUE_FULL          , "The DNS lookup queue is full")
 XPC_MSG_DEF(NS_ERROR_UNKNOWN_PROXY_HOST             , "The lookup of the proxy hostname failed")
 XPC_MSG_DEF(NS_ERROR_UNKNOWN_SOCKET_TYPE            , "The specified socket type does not exist")
 XPC_MSG_DEF(NS_ERROR_SOCKET_CREATE_FAILED           , "The specified socket type could not be created")
+XPC_MSG_DEF(NS_ERROR_SOCKET_ADDRESS_NOT_SUPPORTED   , "The specified socket address type is not supported")
 XPC_MSG_DEF(NS_ERROR_CACHE_KEY_NOT_FOUND            , "Cache key could not be found")
 XPC_MSG_DEF(NS_ERROR_CACHE_DATA_IS_STREAM           , "Cache data is a stream")
 XPC_MSG_DEF(NS_ERROR_CACHE_DATA_IS_NOT_STREAM       , "Cache data is not a stream")
 XPC_MSG_DEF(NS_ERROR_CACHE_WAIT_FOR_VALIDATION      , "Cache entry exists but needs to be validated first")
 XPC_MSG_DEF(NS_ERROR_CACHE_ENTRY_DOOMED             , "Cache entry has been  doomed")
 XPC_MSG_DEF(NS_ERROR_CACHE_READ_ACCESS_DENIED       , "Read access to cache denied")
 XPC_MSG_DEF(NS_ERROR_CACHE_WRITE_ACCESS_DENIED      , "Write access to cache denied")
 XPC_MSG_DEF(NS_ERROR_CACHE_IN_USE                   , "Cache is currently in use")
--- a/netwerk/base/src/nsSocketTransport2.cpp
+++ b/netwerk/base/src/nsSocketTransport2.cpp
@@ -155,20 +155,22 @@ ErrorAccordingToNSPR(PRErrorCode errorCo
         rv = NS_ERROR_NET_INTERRUPT;
         break;
     case PR_CONNECT_REFUSED_ERROR:
     case PR_NETWORK_UNREACHABLE_ERROR: // XXX need new nsresult for this!
     case PR_HOST_UNREACHABLE_ERROR:    // XXX and this!
     case PR_ADDRESS_NOT_AVAILABLE_ERROR:
     // Treat EACCES as a soft error since (at least on Linux) connect() returns
     // EACCES when an IPv6 connection is blocked by a firewall. See bug 270784.
-    case PR_ADDRESS_NOT_SUPPORTED_ERROR:
     case PR_NO_ACCESS_RIGHTS_ERROR:
         rv = NS_ERROR_CONNECTION_REFUSED;
         break;
+    case PR_ADDRESS_NOT_SUPPORTED_ERROR:
+        rv = NS_ERROR_SOCKET_ADDRESS_NOT_SUPPORTED;
+        break;
     case PR_IO_TIMEOUT_ERROR:
     case PR_CONNECT_TIMEOUT_ERROR:
         rv = NS_ERROR_NET_TIMEOUT;
         break;
     default:
         if (IsNSSErrorCode(errorCode))
             rv = GetXPCOMFromNSSError(errorCode);
         break;
--- a/xpcom/base/ErrorList.h
+++ b/xpcom/base/ErrorList.h
@@ -246,17 +246,18 @@
 
 
   /* Socket specific error codes: */
 
   /* The specified socket type does not exist. */
   ERROR(NS_ERROR_UNKNOWN_SOCKET_TYPE,   FAILURE(51)),
   /* The specified socket type could not be created. */
   ERROR(NS_ERROR_SOCKET_CREATE_FAILED,  FAILURE(52)),
-
+  /* The operating system doesn't support the given type of address. */
+  ERROR(NS_ERROR_SOCKET_ADDRESS_NOT_SUPPORTED, FAILURE(53)),
 
   /* Cache specific error codes: */
   ERROR(NS_ERROR_CACHE_KEY_NOT_FOUND,        FAILURE(61)),
   ERROR(NS_ERROR_CACHE_DATA_IS_STREAM,       FAILURE(62)),
   ERROR(NS_ERROR_CACHE_DATA_IS_NOT_STREAM,   FAILURE(63)),
   ERROR(NS_ERROR_CACHE_WAIT_FOR_VALIDATION,  FAILURE(64)),
   ERROR(NS_ERROR_CACHE_ENTRY_DOOMED,         FAILURE(65)),
   ERROR(NS_ERROR_CACHE_READ_ACCESS_DENIED,   FAILURE(66)),