Here is what is currently in lock_wait():

function lock_wait($name, $delay = 30) {
  $delay = (int) $delay * 1000000;
  // Begin sleeping at 25ms.
  $sleep = 25000;

Currently, PHP will cast any $delay value as an integer before it ever has a chance to be multiplied by 1 million, causing delay values such as '1.5' to round down and produce unexpected results.

function lock_wait($name, $delay = 30) {
  $delay = (int) ($delay * 1000000);
  // Begin sleeping at 25ms.
  $sleep = 25000;

Adding parenthesis around the values to be multiplied fixes this. This is already an issue in core: https://drupal.org/node/2096259.

CommentFileSizeAuthor
#1 memcache-lock_wait_delay-2194949-1.patch521 bytesAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Attached is a patch rolled against 7.x-1.x. This issue also exists on 6.x-1.x but I don't see any issues on 8.x-2.x.

Jeremy’s picture

Category: Bug report » Feature request
Status: Active » Needs work

IMO this is a feature request, as we currently implement the same functionality as core.

In order to merge this, the patch also needs to update the inline documentation ($delay is currently defined as an integer).

(The core issue is marked as a bug because of the discrepancy between lock_acquire and lock_wait -- in the case of memcache, lock_acquire has to be an integer because of http://www.php.net/manual/en/memcache.add.php so we have no discrepancy -- both are integers.)

Jeremy’s picture

Assigned: » Unassigned
Status: Needs work » Closed (won't fix)

no followup, closing