Lines 2267-2272
Link Here
|
2267 |
} |
2267 |
} |
2268 |
#endif /* USE_ALTERNATE_IS_CONNECTED */ |
2268 |
#endif /* USE_ALTERNATE_IS_CONNECTED */ |
2269 |
|
2269 |
|
|
|
2270 |
apr_status_t bind_to_addr(apr_socket_t *newsock, apr_sockaddr_t *laddr, |
2271 |
const char *proxy_function, proxy_worker *worker, server_rec *s) |
2272 |
{ |
2273 |
const int idx = worker->bind_idx; |
2274 |
const int range = worker->bind_range; |
2275 |
const int start = worker->bind_port; |
2276 |
for(int i = 0; i < range; ++i) { /* loop until we can bind correctly*/ |
2277 |
int port = start + ((idx + i) % range); |
2278 |
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "proxy: %s: trying to bind to %s:%u", |
2279 |
proxy_function, laddr,port, NULL); |
2280 |
|
2281 |
laddr->sa.sin.sin_port = htons(port); |
2282 |
laddr->port = port; |
2283 |
if (apr_socket_bind(newsock, laddr) == APR_SUCCESS) { |
2284 |
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "proxy: %s: bound to %s:%u", |
2285 |
proxy_function, laddr, laddr->port, NULL); |
2286 |
worker->bind_idx = i + 1; |
2287 |
return APR_SUCCESS; |
2288 |
} |
2289 |
} |
2290 |
return APR_EINVAL; |
2291 |
} |
2292 |
|
2293 |
|
2270 |
PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function, |
2294 |
PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function, |
2271 |
proxy_conn_rec *conn, |
2295 |
proxy_conn_rec *conn, |
2272 |
proxy_worker *worker, |
2296 |
proxy_worker *worker, |
Lines 2349-2354
Link Here
|
2349 |
"proxy: %s: fam %d socket created to connect to %s", |
2373 |
"proxy: %s: fam %d socket created to connect to %s", |
2350 |
proxy_function, backend_addr->family, worker->hostname); |
2374 |
proxy_function, backend_addr->family, worker->hostname); |
2351 |
|
2375 |
|
|
|
2376 |
if (worker->bindopt_set) { |
2377 |
rv = APR_EINVAL; |
2378 |
for(apr_sockaddr_t *addr = worker->bind_addr; addr; addr = addr->next) { |
2379 |
if (addr->family != backend_addr->family) continue; |
2380 |
rv = bind_to_addr(newsock, addr, proxy_function, worker, s); |
2381 |
if (rv == APR_SUCCESS) break; |
2382 |
} |
2383 |
if (rv != APR_SUCCESS) { |
2384 |
ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "proxy: %s: can not bind to %s:%u+%u", |
2385 |
proxy_function,worker->bind_addr, worker->bind_port, worker->bind_range, NULL); |
2386 |
return DECLINED; |
2387 |
} |
2388 |
} |
2389 |
|
2352 |
/* make the connection out of the socket */ |
2390 |
/* make the connection out of the socket */ |
2353 |
rv = apr_socket_connect(newsock, backend_addr); |
2391 |
rv = apr_socket_connect(newsock, backend_addr); |
2354 |
|
2392 |
|