server: Fix fake "Address already in use" error

In the current workflow, socket file will be deleted if it already exists.
However, if the socket file is a symbolic link and the file that it refers
to doesn't exist, we will got "Address already in use" because bind()
thinks the socket file exists and won't create it.

Now, use lstat() to determine whether the socket file exists.

Signed-off-by: Liu Wenlong <liuwl.fnst@cn.fujitsu.com>
This commit is contained in:
Liu Wenlong 2019-08-26 17:08:22 +08:00
parent 17e49ba844
commit 152c9ed968

View File

@ -1393,7 +1393,7 @@ wl_socket_lock(struct wl_socket *socket)
goto err_fd;
}
if (stat(socket->addr.sun_path, &socket_stat) < 0 ) {
if (lstat(socket->addr.sun_path, &socket_stat) < 0 ) {
if (errno != ENOENT) {
wl_log("did not manage to stat file %s\n",
socket->addr.sun_path);