diff options
author | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2000-04-03 03:35:00 +0000 |
---|---|---|
committer | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2000-04-03 03:35:00 +0000 |
commit | 2dbd5b16305078cca1621536aeb89c7f800454a9 (patch) | |
tree | 11e366aa80cae5c579b38d6a6a2977f69fc24a37 /network_io | |
parent | 80847525785dfcfab87aff005f424f9cbd1cb627 (diff) | |
download | libapr-2dbd5b16305078cca1621536aeb89c7f800454a9.tar.gz |
Don't use the values of resolver error codes for the
corresponding APR error codes. On Unix, return the proper
APR error code after a resolver error.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@59764 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r-- | network_io/unix/networkio.h | 2 | ||||
-rw-r--r-- | network_io/unix/sockets.c | 5 | ||||
-rw-r--r-- | network_io/unix/sockopt.c | 30 |
3 files changed, 31 insertions, 6 deletions
diff --git a/network_io/unix/networkio.h b/network_io/unix/networkio.h index aff8cb1fe..d919ba9b1 100644 --- a/network_io/unix/networkio.h +++ b/network_io/unix/networkio.h @@ -136,5 +136,7 @@ struct pollfd_t { ap_int16_t get_event(ap_int16_t); ap_int16_t get_revent(ap_int16_t); +ap_status_t status_from_res_error(int); + #endif /* ! NETWORK_IO_H */ diff --git a/network_io/unix/sockets.c b/network_io/unix/sockets.c index cf9efe641..68c9a887c 100644 --- a/network_io/unix/sockets.c +++ b/network_io/unix/sockets.c @@ -231,10 +231,7 @@ ap_status_t ap_connect(struct socket_t *sock, char *hostname) return APR_ENOTSOCK; } if (!hp) { - if (h_errno == TRY_AGAIN) { - return EAGAIN; - } - return h_errno; + return status_from_res_error(h_errno); } memcpy((char *)&sock->remote_addr->sin_addr, hp->h_addr_list[0], hp->h_length); diff --git a/network_io/unix/sockopt.c b/network_io/unix/sockopt.c index 9e45ae9ed..9c53d9727 100644 --- a/network_io/unix/sockopt.c +++ b/network_io/unix/sockopt.c @@ -207,8 +207,34 @@ ap_status_t ap_get_remote_hostname(char **name, struct socket_t *sock) return APR_ENOMEM; } - /* XXX - Is this threadsafe? */ - return h_errno; + /* XXX - Is referencing h_errno threadsafe? */ + return status_from_res_error(h_errno); } +ap_status_t status_from_res_error(int herr) +{ + ap_status_t status; + switch(herr) { + case HOST_NOT_FOUND: + status = APR_EHOSTNOTFOUND; + break; + case TRY_AGAIN: + status = APR_EAGAIN; + break; + case NO_RECOVERY: + status = APR_ENORECOVERY; + break; + case NO_ADDRESS: + status = APR_ENOADDRESS; + break; +#if defined(NO_DATA) && (NO_ADDRESS != NO_DATA) + case NO_DATA: +#endif + status = APR_ENODATA; + break; + default: + status = APR_ENORECOVERY; + } + return status; +} |