Sorry, meant to post this to the newsgroup, not directly to WTC.
-------- Original Message --------
Subject: Re: Unix platforms shouldn't mask errors specific to Unix
domain sockets
Date: Sun, 18 Aug 2013 20:34:58 -0700
From: Jim Blandy <
ji...@mozilla.com>
To: Wan-Teh Chang <
w...@google.com>
(Huh. The attached patch does show up in the archives here:
https://groups.google.com/d/msg/mozilla.dev.tech.nspr/F57agalOUTw/6J9lHhVDK8UJ
I've included it directly below.)
The patch actually deletes all the switch cases in
_MD_unix_map_connect_error that map errno values to
PR_ADDRESS_NOT_SUPPORTED_ERROR. Deleting those cases has the effect of
delegating those values to _MD_unix_map_default_error, which does map
EACCES to PR_NO_ACCESS_RIGHTS_ERROR, as you suggest.
The errors this affects are those that arise only when using Unix-domain
sockets --- with the exception (that I know of) of EACCES, which Linux
will return for IP and IPv6 addresses if firewall rules forbid the
connection. Even there, I think PR_NO_ACCESS_RIGHTS_ERROR would be the
more informative status to return.
If there are NSPR clients out there that are checking for
PR_ADDRESS_NOT_SUPPORTED_ERROR while using Unix-domain sockets, they're
not going be doing very sophisticated error recovery based on those
codes. If I've thought this through right, then although the patch is
not a backwards-compatible change, it is one that will probably have
little effect beyond improving error messages.
----
Don't mask filesystem-related errors when using Unix domain sockets.
Instead, let _MD_unix_map_default_error handle them normally.
diff --git a/pr/src/md/unix/unix_errors.c b/pr/src/md/unix/unix_errors.c
--- a/pr/src/md/unix/unix_errors.c
+++ b/pr/src/md/unix/unix_errors.c
@@ -528,9 +528,6 @@ void _MD_unix_map_connect_error(int err)
PRErrorCode prError;
switch (err) {
- case EACCES:
- prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
- break;
#if defined(UNIXWARE)
/*
* On some platforms, if we connect to a port on the local host
@@ -541,12 +538,6 @@ void _MD_unix_map_connect_error(int err)
prError = PR_CONNECT_REFUSED_ERROR;
break;
#endif
- case ELOOP:
- prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
- break;
- case ENOENT:
- prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
- break;
case ENXIO:
prError = PR_IO_ERROR;
break;
@@ -565,17 +556,6 @@ void _MD_unix_map_bind_error(int err)
case EINVAL:
prError = PR_SOCKET_ADDRESS_IS_BOUND_ERROR;
break;
- /*
- * UNIX domain sockets are not supported in NSPR
- */
- case EIO:
- case EISDIR:
- case ELOOP:
- case ENOENT:
- case ENOTDIR:
- case EROFS:
- prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
- break;
default:
_MD_unix_map_default_error(err);
return;