Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Cache: Optimized Filesystem::setItem with locking enabled by writing the... #3217

Closed
wants to merge 1 commit into from

2 participants

@marc-mabe

... file in non-blocking mode- than delete a related tag file - and after this retry writing file in blocking mode if it was blocked before

@marc-mabe marc-mabe Cache: Optimized Filesystem::setItem with locking enabled by writing …
…the file in non-blocking mode than delete a related tag file and after this retry writing file in blocking mode if it was blocked before
4b65908
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3217'
Close #3217
37f031d
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3217' into develop
Forward port #3217
0a2f2c1
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-cache
@weierophinney weierophinney Merge branch 'hotfix/3217' 4fe9653
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-cache
@weierophinney weierophinney Merge branch 'hotfix/3217' into develop 169e4db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 13, 2012
  1. @marc-mabe

    Cache: Optimized Filesystem::setItem with locking enabled by writing …

    marc-mabe authored
    …the file in non-blocking mode than delete a related tag file and after this retry writing file in blocking mode if it was blocked before
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 2 deletions.
  1. +11 −2 library/Zend/Cache/Storage/Adapter/Filesystem.php
View
13 library/Zend/Cache/Storage/Adapter/Filesystem.php
@@ -880,9 +880,18 @@ protected function internalSetItem(& $normalizedKey, & $value)
$filespec = $this->getFileSpec($normalizedKey);
$this->prepareDirectoryStructure($filespec);
- $this->putFileContent($filespec . '.dat', $value);
+ // write data in non-blocking mode
+ $wouldblock = null;
+ $this->putFileContent($filespec . '.dat', $value, true, $wouldblock);
+
+ // delete related tag file (if present)
$this->unlink($filespec . '.tag');
+ // Retry writing data in blocking mode if it was blocked before
+ if ($wouldblock) {
+ $this->putFileContent($filespec . '.dat', $value);
+ }
+
return true;
}
@@ -1528,7 +1537,7 @@ protected function putFileContent($file, $data, $nonBlocking = false, & $wouldbl
}
}
- if (!fwrite($fp, $data)) {
+ if (fwrite($fp, $data) === false) {
flock($fp, \LOCK_UN);
fclose($fp);
$err = ErrorHandler::stop();
Something went wrong with that request. Please try again.