View | Details | Raw Unified | Return to bug 50551
Collapse All | Expand All

(-)httpd-2.2.18-original/modules/proxy/mod_proxy.c (+9 lines)
Lines 101-106 Link Here
101
            return "TTL must be at least one second";
101
            return "TTL must be at least one second";
102
        worker->ttl = apr_time_from_sec(ival);
102
        worker->ttl = apr_time_from_sec(ival);
103
    }
103
    }
104
    else if (!strcasecmp(key, "dnsto")) {
105
        /* Time in seconds that will cause a new dns lookup
106
         * for the connection
107
         */
108
        ival = atoi(val);
109
        if (ival < 1)
110
            return "DNSTO must be at least one second";
111
        worker->dnsto = apr_time_from_sec(ival);
112
    }
104
    else if (!strcasecmp(key, "min")) {
113
    else if (!strcasecmp(key, "min")) {
105
        /* Initial number of connections to remote
114
        /* Initial number of connections to remote
106
         */
115
         */
(-)httpd-2.2.18-original/modules/proxy/mod_proxy.h (+1 lines)
Lines 358-363 Link Here
358
    char            disablereuse_set;
358
    char            disablereuse_set;
359
    apr_interval_time_t conn_timeout;
359
    apr_interval_time_t conn_timeout;
360
    char            conn_timeout_set;
360
    char            conn_timeout_set;
361
    apr_interval_time_t dnsto;	/* Timeout for the stored ip address to be looked up again */
361
};
362
};
362
363
363
/*
364
/*
(-)httpd-2.2.18-original/modules/proxy/proxy_util.c (-1 / +50 lines)
Lines 49-54 Link Here
49
static int proxy_match_domainname(struct dirconn_entry *This, request_rec *r);
49
static int proxy_match_domainname(struct dirconn_entry *This, request_rec *r);
50
static int proxy_match_hostname(struct dirconn_entry *This, request_rec *r);
50
static int proxy_match_hostname(struct dirconn_entry *This, request_rec *r);
51
static int proxy_match_word(struct dirconn_entry *This, request_rec *r);
51
static int proxy_match_word(struct dirconn_entry *This, request_rec *r);
52
static char *get_addr(char *buf, apr_sockaddr_t *sa);
52
53
53
APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, PROXY, int, create_req,
54
APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, PROXY, int, create_req,
54
                                   (request_rec *r, request_rec *pr), (r, pr),
55
                                   (request_rec *r, request_rec *pr), (r, pr),
Lines 2026-2039 Link Here
2026
                                               proxy_conn_rec *conn,
2027
                                               proxy_conn_rec *conn,
2027
                                               server_rec *s)
2028
                                               server_rec *s)
2028
{
2029
{
2030
    char old_address[512];
2031
    char new_address[512];
2032
    int dnsto;
2033
2029
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
2034
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
2030
                 "proxy: %s: has released connection for (%s)",
2035
                 "proxy: %s: has released connection for (%s)",
2031
                 proxy_function, conn->worker->hostname);
2036
                 proxy_function, conn->worker->hostname);
2032
    connection_cleanup(conn);
2037
2038
    dnsto = apr_time_sec(conn->worker->dnsto);
2039
    if (dnsto) {
2040
        apr_status_t return_value;
2041
        const char *hostname = conn->worker->hostname;
2042
        const apr_port_t port = conn->worker->port;
2043
        apr_sockaddr_t *old_sock_addr = conn->addr;
2044
        apr_sockaddr_t *new_sock_addr;
2045
        apr_pool_t *pool;
2046
        return_value = apr_pool_create(&pool, conn->pool);
2047
        apr_sockaddr_info_get(&new_sock_addr, hostname, APR_UNSPEC, port, 0, pool);
2048
        get_addr(old_address, old_sock_addr);
2049
        get_addr(new_address, new_sock_addr);
2050
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
2051
                "proxy: ip of connection is %pI, the current resolved ip is %pI",
2052
                old_sock_addr, new_sock_addr);
2053
        if (strcmp(old_address, new_address)) {
2054
            ap_log_error(APLOG_MARK, APLOG_INFO, 0, s,
2055
                    "proxy: Invalidating the connection due to change in dns resolved address.");
2056
            /*
2057
             * If the address has changed, store the changed
2058
             * address in all relevant places and mark the
2059
             * connection as due to be closed.
2060
             */
2061
            conn->worker->cp->addr = new_sock_addr;
2062
            conn->addr = new_sock_addr;
2063
            conn->connection->remote_addr = new_sock_addr;
2064
            conn->close = 1;
2065
        }
2066
    }
2067
2068
    connection_cleanup(conn, s);
2033
2069
2034
    return OK;
2070
    return OK;
2035
}
2071
}
2036
2072
2073
static char *get_addr(char *p, apr_sockaddr_t *sa)
2074
{
2075
    apr_size_t sub_len;
2076
2077
    if (apr_sockaddr_ip_getbuf(p, sa->addr_str_len, sa)) {
2078
        /* Should only fail if the buffer is too small, which it
2079
         * should not be; but fail safe anyway: */
2080
        strcpy(p, "?");
2081
    }
2082
2083
    return (p);
2084
}
2085
2037
PROXY_DECLARE(int)
2086
PROXY_DECLARE(int)
2038
ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
2087
ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
2039
                              proxy_server_conf *conf,
2088
                              proxy_server_conf *conf,

Return to bug 50551