mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 15:17:01 +02:00
MINOR: proto_ux: ability to dump ABNS names in error messages
In sock_unix_bind_receiver(), uxst_bind_listener() and uxdg_bind_listener(), properly dump ABNS socket names by leveraging sa2str() function which does the hard work for us. UNIX sockets are reported as is (unchanged) while ABNS UNIX sockets are prefixed with 'abns@' to match the syntax used in config file. (they where previously showing as empty strings because of the leading NULL-byte that was not properly handled in this case) This is only a minor debug improvement, however it could be useful to backport it up to 2.4. [for 2.4: you should replace "%s [%s]" by "%s for [%s]" for uxst and uxgd if you wan't the patch to apply properly]
This commit is contained in:
parent
2338dba18d
commit
de63efba5a
@ -29,6 +29,7 @@
|
||||
#include <haproxy/protocol.h>
|
||||
#include <haproxy/sock.h>
|
||||
#include <haproxy/sock_unix.h>
|
||||
#include <haproxy/tools.h>
|
||||
|
||||
static int uxdg_bind_listener(struct listener *listener, char *errmsg, int errlen);
|
||||
static void uxdg_enable_listener(struct listener *listener);
|
||||
@ -103,8 +104,11 @@ int uxdg_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
|
||||
uxdg_return:
|
||||
if (msg && errlen) {
|
||||
const char *path = ((struct sockaddr_un *)&listener->rx.addr)->sun_path;
|
||||
snprintf(errmsg, errlen, "%s for [%s]", msg, path);
|
||||
char *path_str;
|
||||
|
||||
path_str = sa2str((struct sockaddr_storage *)&listener->rx.addr, 0, 0);
|
||||
snprintf(errmsg, errlen, "%s for [%s]", msg, ((path_str) ? path_str : ""));
|
||||
ha_free(&path_str);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
@ -142,8 +142,11 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
|
||||
close(fd);
|
||||
uxst_return:
|
||||
if (msg && errlen) {
|
||||
const char *path = ((struct sockaddr_un *)&listener->rx.addr)->sun_path;
|
||||
snprintf(errmsg, errlen, "%s for [%s]", msg, path);
|
||||
char *path_str;
|
||||
|
||||
path_str = sa2str((struct sockaddr_storage *)&listener->rx.addr, 0, 0);
|
||||
snprintf(errmsg, errlen, "%s for [%s]", msg, ((path_str) ? path_str : ""));
|
||||
ha_free(&path_str);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
@ -337,8 +337,13 @@ int sock_unix_bind_receiver(struct receiver *rx, char **errmsg)
|
||||
unlink(backname);
|
||||
bind_return:
|
||||
if (errmsg && *errmsg) {
|
||||
if (!ext)
|
||||
memprintf(errmsg, "%s [%s]", *errmsg, path);
|
||||
if (!ext) {
|
||||
char *path_str;
|
||||
|
||||
path_str = sa2str((struct sockaddr_storage *)&rx->addr, 0, 0);
|
||||
memprintf(errmsg, "%s [%s]", *errmsg, ((path_str) ? path_str : ""));
|
||||
ha_free(&path_str);
|
||||
}
|
||||
else
|
||||
memprintf(errmsg, "%s [fd %d]", *errmsg, fd);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user