r70014 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70013‎ | r70014 | r70015 >
Date:13:56, 27 July 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
For each download, there is a slow svn up, which locks the working copy.
Another download at the same time will produce the 'cleanup needed' error.

Replace the svn up with a remote svn info, which is equally slow but
non-locking. Then only svn up if it has really changed.
Modified paths:
  • /trunk/extensions/ExtensionDistributor/svn-invoker.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ExtensionDistributor/svn-invoker.php
@@ -71,36 +71,58 @@
7272 }
7373 $version = $command->version;
7474 $extension = $command->extension;
 75+ $dir = "$wgExtDistWorkingCopy/$version/extensions/$extension";
7576
76 - // svn up
77 - $dir = "$wgExtDistWorkingCopy/$version/extensions/$extension";
78 - $cmd = "svn up --non-interactive " . escapeshellarg( $dir ) . " 2>&1";
79 - $retval = - 1;
80 - $result = svnShellExec( $cmd, $retval );
81 - if ( $retval ) {
82 - svnError( 'extdist-svn-error', $result );
 77+ // Determine last changed revision in the checkout
 78+ $localRev = svnGetRev( $dir, &$remoteDir );
 79+ if ( !$localRev ) {
8380 return;
8481 }
 82+
 83+ // Determine last changed revision in the repo
 84+ $remoteRev = svnGetRev( $remoteDir );
 85+ if ( !$remoteRev ) {
 86+ return;
 87+ }
 88+
 89+ if ( $remoteRev != $localRev ) {
 90+ // Bad luck, we need to svn up
 91+ $cmd = "svn up --non-interactive " . escapeshellarg( $dir ) . " 2>&1";
 92+ $retval = - 1;
 93+ $result = svnShellExec( $cmd, $retval );
 94+ if ( $retval ) {
 95+ svnError( 'extdist-svn-error', $result );
 96+ return;
 97+ }
 98+ }
 99+
 100+ echo json_encode( array( 'revision' => $remoteRev ) );
 101+}
85102
86 - // Determine last changed revision
 103+// Returns the last changed revision or false
 104+// @param $dir Path or url of the folder
 105+// Output param $url Remote location of the folder
 106+function svnGetRev( $dir, &$url = null ) {
 107+
87108 $cmd = "svn info --non-interactive --xml " . escapeshellarg( $dir );
88109 $retval = - 1;
89110 $result = svnShellExec( $cmd, $retval );
90111 if ( $retval ) {
91112 svnError( 'extdist-svn-error', $result );
92 - return;
 113+ return false;
93114 }
94115
95116 try {
96117 $sx = new SimpleXMLElement( $result );
97118 $rev = strval( $sx->entry->commit['revision'] );
 119+ $url = $sx->entry->url;
98120 } catch ( Exception $e ) {
99121 $rev = false;
100122 }
101123 if ( !$rev || strpos( $rev, '/' ) !== false || strpos( $rev, "\000" ) !== false ) {
102124 svnError( 'extdist-svn-parse-error', $result );
103 - return;
 125+ return false;
104126 }
105 -
106 - echo json_encode( array( 'revision' => $rev ) );
 127+
 128+ return $rev;
107129 }

Comments

#Comment by Tim Starling (talk | contribs)   15:17, 27 July 2010

The commit message is completely wrong. The xinetd service is limited to one instance. Another request at the same time will just wait for the first one to complete, it won't produce any errors.

#Comment by Platonides (talk | contribs)   21:46, 27 July 2010

I probably misunderstood something from the irc log.

Status & tagging log