mirror of
https://github.com/curl/curl.git
synced 2026-07-26 14:37:16 +03:00
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 to0882e3951d#22026 Follow-up to03bc93bd32#22021 Follow-up toe70f8ebd34#22020 Follow-up to30e491e5c9#7034 Follow-up to99fb36797aCloses #22010
This commit is contained in:
parent
eb6d1e098e
commit
0dae3b2690
1 changed files with 3 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue