Merge pull request #24299 from owncloud/availability-avoid-concurrency

Prevent concurrent storage availability checks
This commit is contained in:
Thomas Müller 2016-04-29 17:43:31 +02:00
commit e59ccc5fe9
2 changed files with 9 additions and 2 deletions

View File

@ -40,9 +40,13 @@ class Availability extends Wrapper {
}
/**
* Only called if availability === false
*
* @return bool
*/
private function updateAvailability() {
// reset availability to false so that multiple requests don't recheck concurrently
$this->setAvailability(false);
try {
$result = $this->test();
} catch (\Exception $e) {

View File

@ -74,9 +74,12 @@ class Availability extends \Test\TestCase {
$storage->expects($this->once())
->method('test')
->willReturn(true);
$storage->expects($this->once())
$storage->expects($this->exactly(2))
->method('setAvailability')
->with($this->equalTo(true));
->withConsecutive(
[$this->equalTo(false)], // prevents concurrent rechecks
[$this->equalTo(true)] // sets correct availability
);
$storage->expects($this->once())
->method('mkdir');