[prev in list] [next in list] [prev in thread] [next in thread]
List: xen-cvs
Subject: [xen master] vchan-socket-proxy: Move perror() into listen_socket
From: patchbot () xen ! org
Date: 2020-06-29 6:33:42
Message-ID: E1jpnMM-00022D-GK () xenbits ! xenproject ! org
[Download RAW message or body]
commit 01b9a28e7d1dc54968d5081bdc089449052df939
Author: Jason Andryuk <jandryuk@gmail.com>
AuthorDate: Wed Jun 10 23:29:28 2020 -0400
Commit: Wei Liu <wl@xen.org>
CommitDate: Fri Jun 26 11:59:38 2020 +0000
vchan-socket-proxy: Move perror() into listen_socket
The use of perror on the return from listen_socket can produce
misleading results like:
UNIX socket path "/tmp/aa....aa" too long (156 >= 108)
listen socket: Success
errno is reset by subsequent system & library calls, so it may be
inaccurate by the time listen_socket returns. Call perror immediately
after failing system calls to print the proper message.
Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
Acked-by: Wei Liu <wl@xen.org>
Reviewed-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Release-acked-by: Paul Durrant <paul@xen.org>
---
tools/libvchan/vchan-socket-proxy.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/libvchan/vchan-socket-proxy.c b/tools/libvchan/vchan-socket-proxy.c
index 6ae1d84143..4edc3a44f5 100644
--- a/tools/libvchan/vchan-socket-proxy.c
+++ b/tools/libvchan/vchan-socket-proxy.c
@@ -188,16 +188,20 @@ static int listen_socket(const char *path_or_fd) {
/* if not a number, assume a socket path */
fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (fd == -1)
+ if (fd == -1) {
+ perror("socket");
return -1;
+ }
addr.sun_family = AF_UNIX;
strcpy(addr.sun_path, path_or_fd);
if (bind(fd, (const struct sockaddr *)&addr, sizeof(addr)) == -1) {
+ perror("bind");
close(fd);
return -1;
}
if (listen(fd, 5) != 0) {
+ perror("listen");
close(fd);
return -1;
}
@@ -419,7 +423,7 @@ int main(int argc, char **argv)
} else {
socket_fd = listen_socket(socket_path);
if (socket_fd == -1) {
- perror("listen socket");
+ fprintf(stderr, "listen socket failed\n");
return 1;
}
}
--
generated by git-patchbot for /home/xen/git/xen.git#master
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic