MINOR: listener: remove the inherited arg to create_listener()

This argument can now safely be determined from fd != -1, let's just
drop it.
This commit is contained in:
Willy Tarreau 2020-09-15 13:50:58 +02:00
parent 328199348b
commit 909c23b086
3 changed files with 6 additions and 13 deletions

View File

@ -87,13 +87,11 @@ void unbind_listener_no_close(struct listener *listener);
* range <portl> to <porth>, and possibly attached to fd <fd> (or -1 for auto * range <portl> to <porth>, and possibly attached to fd <fd> (or -1 for auto
* allocation). The address family is taken from ss->ss_family. The number of * allocation). The address family is taken from ss->ss_family. The number of
* jobs and listeners is automatically increased by the number of listeners * jobs and listeners is automatically increased by the number of listeners
* created. If the <inherited> argument is set to 1, it specifies that the FD * created. It returns non-zero on success, zero on error with the error message
* was obtained from a parent process.
* It returns non-zero on success, zero on error with the error message
* set in <err>. * set in <err>.
*/ */
int create_listeners(struct bind_conf *bc, const struct sockaddr_storage *ss, int create_listeners(struct bind_conf *bc, const struct sockaddr_storage *ss,
int portl, int porth, int fd, int inherited, char **err); int portl, int porth, int fd, char **err);
/* Delete a listener from its protocol's list of listeners. The listener's /* Delete a listener from its protocol's list of listeners. The listener's
* state is automatically updated from LI_ASSIGNED to LI_INIT. The protocol's * state is automatically updated from LI_ASSIGNED to LI_INIT. The protocol's

View File

@ -117,7 +117,6 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
next = dupstr = strdup(str); next = dupstr = strdup(str);
while (next && *next) { while (next && *next) {
int inherited = 0;
struct sockaddr_storage *ss2; struct sockaddr_storage *ss2;
int fd = -1; int fd = -1;
@ -136,7 +135,6 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
if (ss2->ss_family == AF_CUST_EXISTING_FD) { if (ss2->ss_family == AF_CUST_EXISTING_FD) {
socklen_t addr_len; socklen_t addr_len;
inherited = 1;
/* We want to attach to an already bound fd whose number /* We want to attach to an already bound fd whose number
* is in the addr part of ss2 when cast to sockaddr_in. * is in the addr part of ss2 when cast to sockaddr_in.
@ -155,7 +153,6 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
} else if (ss2->ss_family == AF_CUST_SOCKPAIR) { } else if (ss2->ss_family == AF_CUST_SOCKPAIR) {
socklen_t addr_len; socklen_t addr_len;
inherited = 1;
fd = ((struct sockaddr_in *)ss2)->sin_addr.s_addr; fd = ((struct sockaddr_in *)ss2)->sin_addr.s_addr;
addr_len = sizeof(*ss2); addr_len = sizeof(*ss2);
@ -169,7 +166,7 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
} }
/* OK the address looks correct */ /* OK the address looks correct */
if (!create_listeners(bind_conf, ss2, port, end, fd, inherited, err)) { if (!create_listeners(bind_conf, ss2, port, end, fd, err)) {
memprintf(err, "%s for address '%s'.\n", *err, str); memprintf(err, "%s for address '%s'.\n", *err, str);
goto fail; goto fail;
} }

View File

@ -537,13 +537,11 @@ void unbind_listener_no_close(struct listener *listener)
* range <portl> to <porth>, and possibly attached to fd <fd> (or -1 for auto * range <portl> to <porth>, and possibly attached to fd <fd> (or -1 for auto
* allocation). The address family is taken from ss->ss_family. The number of * allocation). The address family is taken from ss->ss_family. The number of
* jobs and listeners is automatically increased by the number of listeners * jobs and listeners is automatically increased by the number of listeners
* created. If the <inherited> argument is set to 1, it specifies that the FD * created. It returns non-zero on success, zero on error with the error message
* was obtained from a parent process.
* It returns non-zero on success, zero on error with the error message
* set in <err>. * set in <err>.
*/ */
int create_listeners(struct bind_conf *bc, const struct sockaddr_storage *ss, int create_listeners(struct bind_conf *bc, const struct sockaddr_storage *ss,
int portl, int porth, int fd, int inherited, char **err) int portl, int porth, int fd, char **err)
{ {
struct protocol *proto = protocol_by_family(ss->ss_family); struct protocol *proto = protocol_by_family(ss->ss_family);
struct listener *l; struct listener *l;
@ -573,7 +571,7 @@ int create_listeners(struct bind_conf *bc, const struct sockaddr_storage *ss,
proto->add(l, port); proto->add(l, port);
if (inherited) if (fd != -1)
l->rx.flags |= RX_F_INHERITED; l->rx.flags |= RX_F_INHERITED;
HA_SPIN_INIT(&l->lock); HA_SPIN_INIT(&l->lock);