r57659 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57658‎ | r57659 | r57660 >
Date:23:54, 12 October 2009
Author:aaron
Status:resolved (Comments)
Tags:
Comment:
* (bug 20595) Don't increment ping value right after setting it the first time (jumping from 0 -> 2)
* Use memc->set() rather than using add(). The later just does an existence check on the current key, which is useless here.
Modified paths:
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -1283,6 +1283,7 @@
12841284 list( $max, $period ) = $limit;
12851285 $summary = "(limit $max in {$period}s)";
12861286 $count = $wgMemc->get( $key );
 1287+ // Already pinged?
12871288 if( $count ) {
12881289 if( $count > $max ) {
12891290 wfDebug( __METHOD__ . ": tripped! $key at $count $summary\n" );
@@ -1293,11 +1294,11 @@
12941295 } else {
12951296 wfDebug( __METHOD__ . ": ok. $key at $count $summary\n" );
12961297 }
 1298+ $wgMemc->incr( $key );
12971299 } else {
12981300 wfDebug( __METHOD__ . ": adding record for $key $summary\n" );
1299 - $wgMemc->add( $key, 1, intval( $period ) );
 1301+ $wgMemc->set( $key, 1, intval( $period ) ); // first ping
13001302 }
1301 - $wgMemc->incr( $key );
13021303 }
13031304
13041305 wfProfileOut( __METHOD__ );

Follow-up revisions

RevisionCommit summaryAuthorDate
r60266Fixed r57659 for high concurrency situationsaaron17:51, 21 December 2009

Comments

#Comment by Tim Starling (talk | contribs)   05:04, 15 December 2009

Using add instead of set prevents it from resetting the count to 1 many times under high concurrency. The original code would have been correct in the high concurrency situation, if it used an initial value of 0 instead of 1.

Status & tagging log