mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
MEDIUM: protocol: do not call proto->bind() anymore from bind_listener()
All protocol's listeners now only take care of themselves and not of the receiver anymore since that's already being done in proto_bind_all(). Now it finally becomes obvious that UDP doesn't need a listener, as the only thing it does is to set the listener's state to LI_LISTEN!
This commit is contained in:
parent
fc974887ce
commit
ad33acf838
@ -162,12 +162,11 @@ static int sockpair_bind_listener(struct listener *listener, char *errmsg, int e
|
||||
if (listener->state != LI_ASSIGNED)
|
||||
return ERR_NONE; /* already bound */
|
||||
|
||||
err = sockpair_bind_receiver(&listener->rx, listener->rx.proto->accept, &msg);
|
||||
if (err != ERR_NONE) {
|
||||
snprintf(errmsg, errlen, "%s", msg);
|
||||
free(msg); msg = NULL;
|
||||
return err;
|
||||
if (!(listener->rx.flags & RX_F_BOUND)) {
|
||||
msg = "receiving socket not bound";
|
||||
goto err_return;
|
||||
}
|
||||
|
||||
listener->state = LI_LISTEN;
|
||||
return err;
|
||||
|
||||
|
@ -561,6 +561,8 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
socklen_t ready_len;
|
||||
char *msg = NULL;
|
||||
|
||||
err = ERR_NONE;
|
||||
|
||||
/* ensure we never return garbage */
|
||||
if (errlen)
|
||||
*errmsg = 0;
|
||||
@ -568,11 +570,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
if (listener->state != LI_ASSIGNED)
|
||||
return ERR_NONE; /* already bound */
|
||||
|
||||
err = sock_inet_bind_receiver(&listener->rx, listener->rx.proto->accept, &msg);
|
||||
if (err != ERR_NONE) {
|
||||
snprintf(errmsg, errlen, "%s", msg);
|
||||
free(msg); msg = NULL;
|
||||
return err;
|
||||
if (!(listener->rx.flags & RX_F_BOUND)) {
|
||||
msg = "receiving socket not bound";
|
||||
goto tcp_return;
|
||||
}
|
||||
|
||||
fd = listener->rx.fd;
|
||||
@ -691,6 +691,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
|
||||
tcp_close_return:
|
||||
close(fd);
|
||||
tcp_return:
|
||||
if (msg && errlen) {
|
||||
char pn[INET6_ADDRSTRLEN];
|
||||
|
||||
|
@ -180,7 +180,6 @@ int udp6_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir)
|
||||
int udp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
{
|
||||
int err = ERR_NONE;
|
||||
void *handler = NULL;
|
||||
char *msg = NULL;
|
||||
|
||||
/* ensure we never return garbage */
|
||||
@ -190,23 +189,11 @@ int udp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
if (listener->state != LI_ASSIGNED)
|
||||
return ERR_NONE; /* already bound */
|
||||
|
||||
switch (listener->bind_conf->frontend->mode) {
|
||||
case PR_MODE_SYSLOG:
|
||||
handler = syslog_fd_handler;
|
||||
break;
|
||||
default:
|
||||
err |= ERR_FATAL | ERR_ALERT;
|
||||
msg = "UDP is not yet supported on this proxy mode";
|
||||
if (!(listener->rx.flags & RX_F_BOUND)) {
|
||||
msg = "receiving socket not bound";
|
||||
goto udp_return;
|
||||
}
|
||||
|
||||
err = sock_inet_bind_receiver(&listener->rx, handler, &msg);
|
||||
|
||||
if (err != ERR_NONE) {
|
||||
snprintf(errmsg, errlen, "%s", msg);
|
||||
free(msg); msg = NULL;
|
||||
return err;
|
||||
}
|
||||
listener->state = LI_LISTEN;
|
||||
|
||||
udp_return:
|
||||
|
@ -103,11 +103,9 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
|
||||
if (listener->state != LI_ASSIGNED)
|
||||
return ERR_NONE; /* already bound */
|
||||
|
||||
err = sock_unix_bind_receiver(&listener->rx, listener->rx.proto->accept, &msg);
|
||||
if (err != ERR_NONE) {
|
||||
snprintf(errmsg, errlen, "%s", msg);
|
||||
free(msg); msg = NULL;
|
||||
return err;
|
||||
if (!(listener->rx.flags & RX_F_BOUND)) {
|
||||
msg = "receiving socket not bound";
|
||||
goto uxst_return;
|
||||
}
|
||||
|
||||
fd = listener->rx.fd;
|
||||
@ -130,6 +128,7 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
|
||||
|
||||
uxst_close_return:
|
||||
close(fd);
|
||||
uxst_return:
|
||||
if (msg && errlen) {
|
||||
const char *path = ((struct sockaddr_un *)&listener->rx.addr)->sun_path;
|
||||
snprintf(errmsg, errlen, "%s [%s]", msg, path);
|
||||
|
Loading…
Reference in New Issue
Block a user