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.
This commit is contained in:
Jim Blandy 2013-09-06 08:06:22 -07:00
Родитель 6d18edee61
Коммит 4f05888198
3 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -166,6 +166,7 @@ XPC_MSG_DEF(NS_ERROR_DNS_LOOKUP_QUEUE_FULL , "The DNS lookup queue is f
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")

Просмотреть файл

@ -160,10 +160,12 @@ ErrorAccordingToNSPR(PRErrorCode errorCode)
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;

Просмотреть файл

@ -251,7 +251,8 @@
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)),