From: Steinar H. Gunderson Date: Sun, 19 Mar 2023 20:35:10 +0000 (+0100) Subject: Fix an extremely long-standing error with mkdir() racing from multiple threads. X-Git-Url: https://git.sesse.net/?p=pr0n;a=commitdiff_plain;h=78229c85e0965be553209569da657ffb0a35366e Fix an extremely long-standing error with mkdir() racing from multiple threads. --- diff --git a/perl/Sesse/pr0n/Common.pm b/perl/Sesse/pr0n/Common.pm index 2799364..101cee6 100644 --- a/perl/Sesse/pr0n/Common.pm +++ b/perl/Sesse/pr0n/Common.pm @@ -226,13 +226,15 @@ sub ensure_disk_location_exists { my $img_dir = $Sesse::pr0n::Config::image_base . "/images/$dir/"; if (! -d $img_dir) { log_info($r, "Need to create new image directory $img_dir"); - mkdir($img_dir) or die "Couldn't create new image directory $img_dir"; + mkdir($img_dir); # Ignore errors, there could be a race. + -d $img_dir or die "Couldn't create new image directory $img_dir"; } my $cache_dir = $Sesse::pr0n::Config::image_base . "/cache/$dir/"; if (! -d $cache_dir) { log_info($r, "Need to create new cache directory $cache_dir"); - mkdir($cache_dir) or die "Couldn't create new image directory $cache_dir"; + mkdir($cache_dir); # Ignore errors, there could be a race. + -d $cache_dir or die "Couldn't create new cache directory $cache_dir"; } }