From 0dae3b2690ad280d010f1ca9073801040aca947b Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 15 Jun 2026 11:18:14 +0200 Subject: [PATCH] servers: accept `lstat()` failing due to the file missing In `bind_unix_socket()`, before retrying `bind()`. Before this patch the code wanted to check if the to-be-deleted unix socket path was indeed a socket, before deleting it and retrying to bind. If `lstat()` failed for any reason, it skipped retry. Fix to retry if `lstat()` failed because of the file missing. Ref: https://pubs.opengroup.org/onlinepubs/9799919799/functions/lstat.html Follow-up to 0882e3951d910b923f3463fa98604df9fcb13a0c #22026 Follow-up to 03bc93bd327e06e86af0b0c14a888f7482affedc #22021 Follow-up to e70f8ebd34edade24df442152f52b361abaf4309 #22020 Follow-up to 30e491e5c921aecca5a16083d8185840dc64eccd #7034 Follow-up to 99fb36797a3f0b64ad20fcb8b83026875640f8e0 Closes #22010 --- tests/server/util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/server/util.c b/tests/server/util.c index 78c954b1cf..7a227bf0a3 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -699,12 +699,13 @@ int bind_unix_socket(curl_socket_t sock, const char *unix_socket, /* socket server is not alive, now check if it was actually a socket. */ { curlx_struct_stat statbuf; - if(lstat(unix_socket, &statbuf)) { + rc = lstat(unix_socket, &statbuf); + if(rc && errno != ENOENT) { logmsg("Error binding socket, failed to stat %s (%d) %s", unix_socket, errno, curlx_strerror(errno, errbuf, sizeof(errbuf))); return -1; } - if((statbuf.st_mode & S_IFMT) != S_IFSOCK) { + if(!rc && (statbuf.st_mode & S_IFMT) != S_IFSOCK) { logmsg("Error binding socket, %s is not a socket", unix_socket); return -1; }