mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 14:51:27 +02:00
CLEANUP: ssl: remove opendir call in ssl_sock_load_cert
Since commit 3180f7b55434 ("MINOR: ssl: load certificates in alphabetical order"), `readdir` was replaced by `scandir`. We can indeed replace it with a check on the previous `stat` call. This micro cleanup can be a good benefit when you have hundreds of bind lines which open TLS certificates directories in terms of syscall, especially in a case of frequent reloads. Signed-off-by: William Dauchy <w.dauchy@criteo.com>
This commit is contained in:
parent
70c5b0e5fd
commit
9a8ef7f51d
@ -4249,7 +4249,6 @@ int ssl_sock_load_cert(char *path, struct bind_conf *bind_conf, char **err)
|
|||||||
{
|
{
|
||||||
struct dirent **de_list;
|
struct dirent **de_list;
|
||||||
int i, n;
|
int i, n;
|
||||||
DIR *dir;
|
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
char *end;
|
char *end;
|
||||||
char fp[MAXPATHLEN+1];
|
char fp[MAXPATHLEN+1];
|
||||||
@ -4265,8 +4264,7 @@ int ssl_sock_load_cert(char *path, struct bind_conf *bind_conf, char **err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (stat(path, &buf) == 0) {
|
if (stat(path, &buf) == 0) {
|
||||||
dir = opendir(path);
|
if (S_ISDIR(buf.st_mode) == 0) {
|
||||||
if (!dir) {
|
|
||||||
ckchs = ckchs_load_cert_file(path, 0, err);
|
ckchs = ckchs_load_cert_file(path, 0, err);
|
||||||
if (!ckchs)
|
if (!ckchs)
|
||||||
return ERR_ALERT | ERR_FATAL;
|
return ERR_ALERT | ERR_FATAL;
|
||||||
@ -4355,7 +4353,6 @@ ignore_entry:
|
|||||||
}
|
}
|
||||||
free(de_list);
|
free(de_list);
|
||||||
}
|
}
|
||||||
closedir(dir);
|
|
||||||
return cfgerr;
|
return cfgerr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user