Index: trunk/phase3/includes/killthread.php |
— | — | @@ -0,0 +1,36 @@ |
| 2 | +<? |
| 3 | + |
| 4 | +# Script to kill a MySQL thread after a specified timeout |
| 5 | + |
| 6 | +$wgCommandLineMode = true; |
| 7 | + |
| 8 | +unset( $IP ); |
| 9 | +ini_set( "allow_url_fopen", 0 ); # For security... |
| 10 | +include_once( "./LocalSettings.php" ); |
| 11 | + |
| 12 | +# Windows requires ';' as separator, ':' for Unix |
| 13 | +$sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":"; |
| 14 | +ini_set( "include_path", "$IP$sep$include_path" ); |
| 15 | + |
| 16 | +include_once( "Setup.php" ); |
| 17 | + |
| 18 | +$wgTitle = Title::newFromText( wfMsg( "badtitle" ) ); |
| 19 | +$wgArticle = new Article($wgTitle); |
| 20 | + |
| 21 | +if ( !$argv[1] || !$argv[2] ) { |
| 22 | + exit(); |
| 23 | +} |
| 24 | + |
| 25 | +$tid = (int)$argv[2]; |
| 26 | + |
| 27 | +# Wait for timeout (this process may be killed during this time) |
| 28 | +$us = floor( $argv[1] * 1000000 ) % 1000000; |
| 29 | +$s = floor( $argv[1] ); |
| 30 | +usleep( $us ); |
| 31 | +sleep( $s ); |
| 32 | + |
| 33 | +# Kill DB thread |
| 34 | +$conn = Database::newFromParams( $wgDBserver, $wgDBsqluser, $wgDBsqlpassword, $wgDBname ); |
| 35 | +$conn->query( "KILL $tid" ); |
| 36 | + |
| 37 | +?> |
Property changes on: trunk/phase3/includes/killthread.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 38 | + native |
Added: svn:keywords |
2 | 39 | + Author Date Id Revision |