Changeset 176449 in webkit
- Timestamp:
- Nov 21, 2014, 8:44:26 AM (12 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
Scripts/webkitperl/httpd.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r176438 r176449 1 2014-11-21 Csaba Osztrogonác <ossy@webkit.org> 2 3 Remove http lock code from webkitperl 4 https://bugs.webkit.org/show_bug.cgi?id=138959 5 6 Reviewed by Alexey Proskuryakov. 7 8 * Scripts/webkitperl/httpd.pm: 9 (cleanUp): 10 (extractLockNumber): Deleted. 11 (getLockFiles): Deleted. 12 (getNextAvailableLockNumber): Deleted. 13 (getLockNumberForCurrentRunning): Deleted. 14 (waitForHTTPDLock): Deleted. 15 (scheduleHttpTesting): Deleted. 16 (getWaitTime): Deleted. 17 1 18 2014-11-20 Hunseop Jeong <hs85.jeong@samsung.com> 2 19 -
trunk/Tools/Scripts/webkitperl/httpd.pm
r165676 r176449 37 37 use File::Spec; 38 38 use File::Spec::Functions; 39 use Fcntl ':flock';40 39 use IPC::Open2; 41 40 … … 53 52 &openHTTPD 54 53 &closeHTTPD 55 &setShouldWaitForUserInterrupt 56 &waitForHTTPDLock 57 &getWaitTime); 54 &setShouldWaitForUserInterrupt); 58 55 %EXPORT_TAGS = ( ); 59 56 @EXPORT_OK = (); … … 61 58 62 59 my $tmpDir = "/tmp"; 63 my $httpdLockPrefix = "WebKitHttpd.lock.";64 my $myLockFile;65 my $exclusiveLockFile = File::Spec->catfile($tmpDir, "WebKit.lock");66 60 my $httpdPidDir = File::Spec->catfile($tmpDir, "WebKit"); 67 61 my $httpdPidFile = File::Spec->catfile($httpdPidDir, "httpd.pid"); … … 265 259 { 266 260 rmdir $httpdPidDir; 267 unlink $exclusiveLockFile; 268 unlink $myLockFile if $myLockFile; 269 } 270 271 sub extractLockNumber 272 { 273 my ($lockFile) = @_; 274 return -1 unless $lockFile; 275 return substr($lockFile, length($httpdLockPrefix)); 276 } 277 278 sub getLockFiles 279 { 280 opendir(TMPDIR, $tmpDir) or die "Could not open " . $tmpDir . "."; 281 my @lockFiles = grep {m/^$httpdLockPrefix\d+$/} readdir(TMPDIR); 282 @lockFiles = sort { extractLockNumber($a) <=> extractLockNumber($b) } @lockFiles; 283 closedir(TMPDIR); 284 return @lockFiles; 285 } 286 287 sub getNextAvailableLockNumber 288 { 289 my @lockFiles = getLockFiles(); 290 return 0 unless @lockFiles; 291 return extractLockNumber($lockFiles[-1]) + 1; 292 } 293 294 sub getLockNumberForCurrentRunning 295 { 296 my @lockFiles = getLockFiles(); 297 return 0 unless @lockFiles; 298 return extractLockNumber($lockFiles[0]); 299 } 300 301 sub waitForHTTPDLock 302 { 303 $waitBeginTime = time; 304 scheduleHttpTesting(); 305 # If we are the only one waiting for Apache just run the tests without any further checking 306 if (scalar getLockFiles() > 1) { 307 my $currentLockFile = File::Spec->catfile($tmpDir, "$httpdLockPrefix" . getLockNumberForCurrentRunning()); 308 my $currentLockPid = <SCHEDULER_LOCK> if (-f $currentLockFile && open(SCHEDULER_LOCK, "<$currentLockFile")); 309 # Wait until we are allowed to run the http tests 310 while ($currentLockPid && $currentLockPid != $$) { 311 $currentLockFile = File::Spec->catfile($tmpDir, "$httpdLockPrefix" . getLockNumberForCurrentRunning()); 312 if ($currentLockFile eq $myLockFile) { 313 $currentLockPid = <SCHEDULER_LOCK> if open(SCHEDULER_LOCK, "<$currentLockFile"); 314 if ($currentLockPid != $$) { 315 print STDERR "\nPID mismatch.\n"; 316 last; 317 } 318 } else { 319 sleep 1; 320 } 321 } 322 } 323 $waitEndTime = time; 324 } 325 326 sub scheduleHttpTesting 327 { 328 # We need an exclusive lock file to avoid deadlocks and starvation and ensure that the scheduler lock numbers are sequential. 329 # The scheduler locks are used to schedule the running test sessions in first come first served order. 330 while (!(open(SEQUENTIAL_GUARD_LOCK, ">$exclusiveLockFile") && flock(SEQUENTIAL_GUARD_LOCK, LOCK_EX|LOCK_NB))) {} 331 $myLockFile = File::Spec->catfile($tmpDir, "$httpdLockPrefix" . getNextAvailableLockNumber()); 332 open(SCHEDULER_LOCK, ">$myLockFile"); 333 print SCHEDULER_LOCK "$$"; 334 print SEQUENTIAL_GUARD_LOCK "$$"; 335 close(SCHEDULER_LOCK); 336 close(SEQUENTIAL_GUARD_LOCK); 337 unlink $exclusiveLockFile; 338 } 339 340 sub getWaitTime 341 { 342 my $waitTime = 0; 343 if ($waitBeginTime && $waitEndTime) { 344 $waitTime = $waitEndTime - $waitBeginTime; 345 } 346 return $waitTime; 347 } 261 }
Note:
See TracChangeset
for help on using the changeset viewer.