Changeset 63476 in webkit
- Timestamp:
- Jul 15, 2010 3:29:44 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r63465 r63476 1 2010-07-15 Adam Roben <aroben@apple.com> 2 3 Make killing Apache more reliable (on both Mac and Windows) 4 5 We previously had two ways of determining whether we had succeeded in 6 killing Apache: 7 1) checking the return value of kill(0, $apachePID) 8 2) checking whether Apache's PID file still exists 9 10 On Cygwin, Apache doesn't always delete its PID file when it exits, 11 making (2) unreliable. We unfortunately misdiagnosed this as an 12 impotency of Perl's kill function, which led to r63177 and r63355. 13 14 Now that we know that the real problem is that Apache doesn't always 15 delete its PID file on Windows, we can make a much better fix: always 16 use method (1) to determine whether we've killed Apache. 17 18 Fixes <http://webkit.org/b/42415> Killing Apache is unreliable, 19 leading to regression test failures (and general annoyance). 20 21 Reviewed by Anders Carlsson. 22 23 * Scripts/webkitperl/httpd.pm: 24 (openHTTPD): Moved killing code from here to killHTTPD. Added a call 25 to delete the PID file in case Apache doesn't do this itself when 26 killed. Our later logic relies on the PID file being deleted after 27 this point. 28 (closeHTTPD): Removed killing logic and changed to just call killHTTPD 29 instead. killHTTPD's logic is a bit different from the logic we had 30 here, for the reasons stated above. 31 (killHTTPD): Added. Code came from openHTTPD. 32 (handleInterrupt): Bonus fix for Mac: don't hang when pressing Ctrl-C! 33 On Mac, don't try to kill Apache when we receive a signal, as Apache 34 will already have been killed by this point (though for some reason 35 this isn't detected by our killing logic in killHTTPD). On Cygwin, we 36 still need to kill Apache manually. 37 1 38 2010-07-15 Sam Weinig <sam@webkit.org> 2 39 -
trunk/WebKitTools/Scripts/webkitperl/httpd.pm
r63355 r63476 155 155 if (0 != kill 0, $oldPid) { 156 156 print "\nhttpd is already running: pid $oldPid, killing...\n"; 157 kill 15, $oldPid; 158 159 my $retryCount = 20; 160 while ((kill(0, $oldPid) != 0) && $retryCount) { 161 sleep 1; 162 --$retryCount; 163 } 164 165 if (!$retryCount) { 157 if (!killHTTPD($oldPid)) { 166 158 cleanUp(); 167 159 die "Timed out waiting for httpd to quit"; 168 160 } 169 161 } 162 unlink $httpdPidFile; 170 163 } 171 164 … … 197 190 { 198 191 close HTTPDIN; 192 my $succeeded = killHTTPD($httpdPid); 193 cleanUp(); 194 unless ($succeeded) { 195 print STDERR "Timed out waiting for httpd to terminate!\n" unless $succeeded; 196 return 0; 197 } 198 return 1; 199 } 200 201 sub killHTTPD 202 { 203 my ($pid) = @_; 204 205 return 1 unless $pid; 206 207 kill 15, $pid; 208 199 209 my $retryCount = 20; 200 if ($httpdPid) { 201 if (isCygwin()) { 202 # Kill the process (and all its child processes) using taskkill, as 203 # perl's kill doesn't seem to work with Apache. A return value of 0 204 # means the process was killed, and return value of 32768 means 205 # there was no process with that PID. We use open/close here 206 # instead of system to avoid having taskkill print to stdout. 207 if (open(TASKKILL, "-|", qw(taskkill /f /t /pid), $httpdPid) && close(TASKKILL) && (!$? || $? == 32768)) { 208 # Cygwin's Apache doesn't delete the PID file itself when 209 # killed. We delete the PID file for it to work around this. 210 unlink $httpdPidFile; 211 } 212 } else { 213 kill 15, $httpdPid; 214 } 215 while (-f $httpdPidFile && $retryCount) { 216 sleep 1; 217 --$retryCount; 218 } 219 } 220 cleanUp(); 221 if (!$retryCount) { 222 print STDERR "Timed out waiting for httpd to terminate!\n"; 223 return 0; 224 } 225 return 1; 210 while (kill(0, $pid) && $retryCount) { 211 sleep 1; 212 --$retryCount; 213 } 214 return $retryCount != 0; 226 215 } 227 216 … … 233 222 sub handleInterrupt 234 223 { 235 closeHTTPD(); 224 # On Cygwin, when we receive a signal Apache is still running, so we need 225 # to kill it. On other platforms (at least Mac OS X), Apache will have 226 # already been killed, and trying to kill it again will cause us to hang. 227 # All we need to do in this case is clean up our own files. 228 if (isCygwin()) { 229 closeHTTPD(); 230 } else { 231 cleanUp(); 232 } 233 236 234 print "\n"; 237 235 exit(1);
Note: See TracChangeset
for help on using the changeset viewer.