1 From 152c9ed968124c253f0be25b76c2a083a21af37e Mon Sep 17 00:00:00 2001
2 From: Liu Wenlong <liuwl.fnst@cn.fujitsu.com>
3 Date: Mon, 26 Aug 2019 17:08:22 +0800
4 Subject: [PATCH] server: Fix fake "Address already in use" error
6 In the current workflow, socket file will be deleted if it already exists.
7 However, if the socket file is a symbolic link and the file that it refers
8 to doesn't exist, we will got "Address already in use" because bind()
9 thinks the socket file exists and won't create it.
11 Now, use lstat() to determine whether the socket file exists.
13 Upstream-Status: Backport [https://gitlab.freedesktop.org/wayland/wayland/merge_requests/35]
15 Signed-off-by: Liu Wenlong <liuwl.fnst@cn.fujitsu.com>
17 src/wayland-server.c | 2 +-
18 1 file changed, 1 insertion(+), 1 deletion(-)
20 diff --git a/src/wayland-server.c b/src/wayland-server.c
21 index 83b984f..3bc6ed7 100644
22 --- a/src/wayland-server.c
23 +++ b/src/wayland-server.c
24 @@ -1393,7 +1393,7 @@ wl_socket_lock(struct wl_socket *socket)
28 - if (stat(socket->addr.sun_path, &socket_stat) < 0 ) {
29 + if (lstat(socket->addr.sun_path, &socket_stat) < 0 ) {
30 if (errno != ENOENT) {
31 wl_log("did not manage to stat file %s\n",
32 socket->addr.sun_path);