build-remote.pl: don't wait forever for the upload lock
In the build hook, don't wait forever to get the upload lock. This ensures progress if another process gets stuck while holding the upload lock.
This commit is contained in:
		
							parent
							
								
									8afd28a922
								
							
						
					
					
						commit
						56042a120a
					
				
					 1 changed files with 17 additions and 3 deletions
				
			
		| 
						 | 
					@ -232,10 +232,24 @@ sub removeRoots {
 | 
				
			||||||
# the same missing path simultaneously, causing the effective network
 | 
					# the same missing path simultaneously, causing the effective network
 | 
				
			||||||
# bandwidth and target disk speed to be divided by N.
 | 
					# bandwidth and target disk speed to be divided by N.
 | 
				
			||||||
my $uploadLock = "$currentLoad/$hostName.upload-lock";
 | 
					my $uploadLock = "$currentLoad/$hostName.upload-lock";
 | 
				
			||||||
sysopen MAINLOCK, "$uploadLock", O_RDWR|O_CREAT, 0600 or die;
 | 
					sysopen UPLOADLOCK, "$uploadLock", O_RDWR|O_CREAT, 0600 or die;
 | 
				
			||||||
flock(MAINLOCK, LOCK_EX) or die;
 | 
					eval {
 | 
				
			||||||
 | 
					    local $SIG{ALRM} = sub { die "alarm\n" };
 | 
				
			||||||
 | 
					    # Don't wait forever, so that a process that gets stuck while
 | 
				
			||||||
 | 
					    # holding the lock doesn't block everybody else indefinitely.
 | 
				
			||||||
 | 
					    # It's safe to continue after a timeout, just (potentially)
 | 
				
			||||||
 | 
					    # inefficient.
 | 
				
			||||||
 | 
					    alarm 15 * 60;
 | 
				
			||||||
 | 
					    flock(UPLOADLOCK, LOCK_EX);
 | 
				
			||||||
 | 
					    alarm 0;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					if ($@) {
 | 
				
			||||||
 | 
					    die unless $@ eq "alarm\n";
 | 
				
			||||||
 | 
					    print STDERR "somebody is hogging $uploadLock, continuing...\n";
 | 
				
			||||||
 | 
					    unlink $uploadLock;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
Nix::CopyClosure::copyTo($hostName, [ @sshOpts ], [ $drvPath, @inputs ], "", "", 0, 0, $maybeSign ne "");
 | 
					Nix::CopyClosure::copyTo($hostName, [ @sshOpts ], [ $drvPath, @inputs ], "", "", 0, 0, $maybeSign ne "");
 | 
				
			||||||
close MAINLOCK;
 | 
					close UPLOADLOCK;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Perform the build.
 | 
					# Perform the build.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue