@@ -2819,11 +2819,20 @@ global mkpidlock_hook
2819
2819
global trymkpidlock_hook
2820
2820
global parse_pidfile_hook
2821
2821
2822
- # allows processes to wait if another process is precompiling a given source already
2823
- function maybe_cachefile_lock (f, pkg:: PkgId , srcpath:: String )
2822
+ # The preferences hash is only known after precompilation so just assume no preferences
2823
+ # meaning that if all other conditions are equal, the same package cannot be precompiled
2824
+ # with different preferences at the same time.
2825
+ compilecache_pidfile_path (pkg:: PkgId ) = compilecache_path (pkg, UInt64 (0 )) * " .pidfile"
2826
+
2827
+ # Allows processes to wait if another process is precompiling a given source already.
2828
+ # The lock file is deleted and precompilation will proceed after `stale_age` seconds if
2829
+ # - the locking process no longer exists
2830
+ # - the lock is held by another host, since processes cannot be checked remotely
2831
+ # or after `stale_age * 25` seconds if it does still exist.
2832
+ function maybe_cachefile_lock (f, pkg:: PkgId , srcpath:: String ; stale_age= 60 )
2824
2833
if @isdefined (mkpidlock_hook) && @isdefined (trymkpidlock_hook) && @isdefined (parse_pidfile_hook)
2825
- pidfile = string (srcpath, " .pidlock " )
2826
- cachefile = invokelatest (trymkpidlock_hook, f, pidfile)
2834
+ pidfile = compilecache_pidfile_path (pkg )
2835
+ cachefile = invokelatest (trymkpidlock_hook, f, pidfile; stale_age )
2827
2836
if cachefile === false
2828
2837
pid, hostname, age = invokelatest (parse_pidfile_hook, pidfile)
2829
2838
verbosity = isinteractive () ? CoreLogging. Info : CoreLogging. Debug
@@ -2834,7 +2843,7 @@ function maybe_cachefile_lock(f, pkg::PkgId, srcpath::String)
2834
2843
end
2835
2844
# wait until the lock is available, but don't actually acquire it
2836
2845
# returning nothing indicates a process waited for another
2837
- return invokelatest (mkpidlock_hook, Returns (nothing ), pidfile)
2846
+ return invokelatest (mkpidlock_hook, Returns (nothing ), pidfile; stale_age )
2838
2847
end
2839
2848
return cachefile
2840
2849
else
0 commit comments