From 99c15b68351b863073b0fa61e9a2b7ad4a80e01b Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Thu, 24 Mar 2005 06:21:57 +0000 Subject: Supress weird warnings when looking up names of local unix connections. --- common/spio.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/common/spio.c b/common/spio.c index a723936..c26f81a 100644 --- a/common/spio.c +++ b/common/spio.c @@ -117,6 +117,18 @@ void spio_attach(spctx_t* ctx, spio_t* io, int fd, struct sockaddr_any* peer) io->fd = fd; + /* Get the address on which we accepted the connection */ + memset(&locaddr, 0, sizeof(locaddr)); + SANY_LEN(locaddr) = sizeof(locaddr); + + if(getsockname(fd, &SANY_ADDR(locaddr), &SANY_LEN(locaddr)) == -1 || + sock_any_ntop(&locaddr, io->localname, MAXPATHLEN, SANY_OPT_NOPORT) == -1) + { + if (errno != EAFNOSUPPORT) + sp_message(ctx, LOG_WARNING, "%s: couldn't get socket address", GET_IO_NAME(io)); + strlcpy(io->localname, "UNKNOWN", MAXPATHLEN); + } + /* If the caller doesn't want the peer then use our own */ if (peer == NULL) peer = &peeraddr; @@ -127,21 +139,11 @@ void spio_attach(spctx_t* ctx, spio_t* io, int fd, struct sockaddr_any* peer) if(getpeername(fd, &SANY_ADDR(*peer), &SANY_LEN(*peer)) == -1 || sock_any_ntop(peer, io->peername, MAXPATHLEN, SANY_OPT_NOPORT) == -1) { - sp_message(ctx, LOG_WARNING, "%s: couldn't get peer address", GET_IO_NAME(io)); + if (errno != EAFNOSUPPORT) + sp_message(ctx, LOG_WARNING, "%s: couldn't get peer address", GET_IO_NAME(io)); strlcpy(io->peername, "UNKNOWN", MAXPATHLEN); } - /* Get the address on which we accepted the connection */ - memset(&locaddr, 0, sizeof(locaddr)); - SANY_LEN(locaddr) = sizeof(locaddr); - - if(getsockname(fd, &SANY_ADDR(locaddr), &SANY_LEN(locaddr)) == -1 || - sock_any_ntop(&locaddr, io->localname, MAXPATHLEN, SANY_OPT_NOPORT) == -1) - { - sp_message(ctx, LOG_WARNING, "%s: couldn't get socket address", GET_IO_NAME(io)); - strlcpy(io->localname, "UNKNOWN", MAXPATHLEN); - } - /* As a double check */ io->line[0] = 0; io->_nx = NULL; -- cgit v1.2.3