mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-27 13:28:32 +00:00
MINOR: sock: make sock_find_compatible_fd() only take a receiver
We don't need to have a listener anymore to find an fd, a receiver with its settings properly set is enough now.
This commit is contained in:
parent
3fd3bdc836
commit
c049c0d5ad
@ -36,7 +36,7 @@ int sock_create_server_socket(struct connection *conn);
|
||||
int sock_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir);
|
||||
int sock_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir);
|
||||
int sock_get_old_sockets(const char *unixsocket);
|
||||
int sock_find_compatible_fd(const struct listener *l);
|
||||
int sock_find_compatible_fd(const struct receiver *rx);
|
||||
|
||||
#endif /* _HAPROXY_SOCK_H */
|
||||
|
||||
|
@ -573,7 +573,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
goto bound;
|
||||
|
||||
if (listener->rx.fd == -1)
|
||||
listener->rx.fd = sock_find_compatible_fd(listener);
|
||||
listener->rx.fd = sock_find_compatible_fd(&listener->rx);
|
||||
|
||||
/* if the listener already has an fd assigned, then we were offered the
|
||||
* fd by an external process (most likely the parent), and we don't want
|
||||
|
@ -113,7 +113,7 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
|
||||
goto bound;
|
||||
|
||||
if (listener->rx.fd == -1)
|
||||
listener->rx.fd = sock_find_compatible_fd(listener);
|
||||
listener->rx.fd = sock_find_compatible_fd(&listener->rx);
|
||||
path = ((struct sockaddr_un *)&listener->rx.addr)->sun_path;
|
||||
|
||||
maxpathlen = MIN(MAXPATHLEN, sizeof(addr.sun_path));
|
||||
|
30
src/sock.c
30
src/sock.c
@ -347,7 +347,7 @@ out:
|
||||
return (ret2);
|
||||
}
|
||||
|
||||
/* When binding the listeners, check if a socket has been sent to us by the
|
||||
/* When binding the receivers, check if a socket has been sent to us by the
|
||||
* previous process that we could reuse, instead of creating a new one. Note
|
||||
* that some address family-specific options are checked on the listener and
|
||||
* on the socket. Typically for AF_INET and AF_INET6, we check for transparent
|
||||
@ -355,7 +355,7 @@ out:
|
||||
* socket is automatically removed from the list so that it's not proposed
|
||||
* anymore.
|
||||
*/
|
||||
int sock_find_compatible_fd(const struct listener *l)
|
||||
int sock_find_compatible_fd(const struct receiver *rx)
|
||||
{
|
||||
struct xfer_sock_list *xfer_sock = xfer_sock_list;
|
||||
int options = 0;
|
||||
@ -363,41 +363,41 @@ int sock_find_compatible_fd(const struct listener *l)
|
||||
int ns_namelen = 0;
|
||||
int ret = -1;
|
||||
|
||||
if (!l->rx.proto->addrcmp)
|
||||
if (!rx->proto->addrcmp)
|
||||
return -1;
|
||||
|
||||
if (l->rx.proto->sock_type == SOCK_DGRAM)
|
||||
if (rx->proto->sock_type == SOCK_DGRAM)
|
||||
options |= SOCK_XFER_OPT_DGRAM;
|
||||
|
||||
if (l->rx.settings->options & RX_O_FOREIGN)
|
||||
if (rx->settings->options & RX_O_FOREIGN)
|
||||
options |= SOCK_XFER_OPT_FOREIGN;
|
||||
|
||||
if (l->rx.addr.ss_family == AF_INET6) {
|
||||
if (rx->addr.ss_family == AF_INET6) {
|
||||
/* Prepare to match the v6only option against what we really want. Note
|
||||
* that sadly the two options are not exclusive to each other and that
|
||||
* v6only is stronger than v4v6.
|
||||
*/
|
||||
if ((l->rx.settings->options & RX_O_V6ONLY) ||
|
||||
(sock_inet6_v6only_default && !(l->rx.settings->options & RX_O_V4V6)))
|
||||
if ((rx->settings->options & RX_O_V6ONLY) ||
|
||||
(sock_inet6_v6only_default && !(rx->settings->options & RX_O_V4V6)))
|
||||
options |= SOCK_XFER_OPT_V6ONLY;
|
||||
}
|
||||
|
||||
if (l->rx.settings->interface)
|
||||
if_namelen = strlen(l->rx.settings->interface);
|
||||
if (rx->settings->interface)
|
||||
if_namelen = strlen(rx->settings->interface);
|
||||
#ifdef USE_NS
|
||||
if (l->rx.settings->netns)
|
||||
ns_namelen = l->rx.settings->netns->name_len;
|
||||
if (rx->settings->netns)
|
||||
ns_namelen = rx->settings->netns->name_len;
|
||||
#endif
|
||||
|
||||
while (xfer_sock) {
|
||||
if ((options == xfer_sock->options) &&
|
||||
(if_namelen == xfer_sock->if_namelen) &&
|
||||
(ns_namelen == xfer_sock->ns_namelen) &&
|
||||
(!if_namelen || strcmp(l->rx.settings->interface, xfer_sock->iface) == 0) &&
|
||||
(!if_namelen || strcmp(rx->settings->interface, xfer_sock->iface) == 0) &&
|
||||
#ifdef USE_NS
|
||||
(!ns_namelen || strcmp(l->rx.settings->netns->node.key, xfer_sock->namespace) == 0) &&
|
||||
(!ns_namelen || strcmp(rx->settings->netns->node.key, xfer_sock->namespace) == 0) &&
|
||||
#endif
|
||||
l->rx.proto->addrcmp(&xfer_sock->addr, &l->rx.addr) == 0)
|
||||
rx->proto->addrcmp(&xfer_sock->addr, &rx->addr) == 0)
|
||||
break;
|
||||
xfer_sock = xfer_sock->next;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user