Commit b34076a2 authored by Joe Orton's avatar Joe Orton
Browse files

* server/listen.c (IS_INADDR_ANY, IS_IN6ADDR_ANY): New macros.

(open_listeners): Simplify using the new macros; no functional change.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@240092 13f79535-47bb-0310-9956-ffa450edef68
parent 9eaf66e8
Loading
Loading
Loading
Loading
+20 −16
Original line number Diff line number Diff line
@@ -339,6 +339,15 @@ static const char *alloc_listener(process_rec *process, char *addr,

    return NULL;
}
/* Evaluates to true if the (apr_sockaddr_t *) addr argument is the
 * IPv4 match-any-address, 0.0.0.0. */
#define IS_INADDR_ANY(addr) ((addr)->family == APR_INET \
                             && (addr)->sa.sin.sin_addr.s_addr == INADDR_ANY)

/* Evaluates to true if the (apr_sockaddr_t *) addr argument is the
 * IPv6 match-any-address, [::]. */
#define IS_IN6ADDR_ANY(addr) ((addr)->family == APR_INET6 \
                              && IN6_IS_ADDR_UNSPECIFIED(&(addr)->sa.sin6.sin6_addr))

/**
 * Create, open, listen, and bind all sockets.
@@ -373,16 +382,13 @@ static int open_listeners(apr_pool_t *pool)
             * listen (which would generate an error). IPv4 will be handled
             * on the established IPv6 socket.
             */
            if (previous != NULL &&
                lr->bind_addr->family == APR_INET &&
                lr->bind_addr->sa.sin.sin_addr.s_addr == INADDR_ANY &&
                lr->bind_addr->port == previous->bind_addr->port &&
                previous->bind_addr->family == APR_INET6 &&
                IN6_IS_ADDR_UNSPECIFIED(
                    &previous->bind_addr->sa.sin6.sin6_addr) &&
                apr_socket_opt_get(previous->sd, APR_IPV6_V6ONLY,
                                   &v6only_setting) == APR_SUCCESS &&
                v6only_setting == 0) {
            if (previous != NULL
                && IS_INADDR_ANY(lr->bind_addr)
                && lr->bind_addr->port == previous->bind_addr->port
                && IS_IN6ADDR_ANY(previous->bind_addr)
                && apr_socket_opt_get(previous->sd, APR_IPV6_V6ONLY,
                                      &v6only_setting) == APR_SUCCESS
                && v6only_setting == 0) {

                /* Remove the current listener from the list */
                previous->next = lr->next;
@@ -400,12 +406,10 @@ static int open_listeners(apr_pool_t *pool)
                 * error. The user will still get a warning from make_sock
                 * though.
                 */
                if (lr->next != NULL && lr->bind_addr->family == APR_INET6 &&
                    IN6_IS_ADDR_UNSPECIFIED(
                        &lr->bind_addr->sa.sin6.sin6_addr) &&
                    lr->bind_addr->port == lr->next->bind_addr->port &&
                    lr->next->bind_addr->family == APR_INET && 
                    lr->next->bind_addr->sa.sin.sin_addr.s_addr == INADDR_ANY) {
                if (lr->next != NULL
                    && IS_IN6ADDR_ANY(lr->bind_addr)
                    && lr->bind_addr->port == lr->next->bind_addr->port
                    && IS_INADDR_ANY(lr->next->bind_addr)) {

                    /* Remove the current listener from the list */
                    if (previous) {