Skip to content

Commit c49bd6c

Browse files
committed
Merge pull request googleapis#475 from kylefarris/patch-1
flock() not getting file handle all the time
2 parents cf392b8 + 55fa097 commit c49bd6c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Google/Cache/File.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ private function acquireLock($type, $storageFile)
170170
{
171171
$mode = $type == LOCK_EX ? "w" : "r";
172172
$this->fh = fopen($storageFile, $mode);
173+
if (!$this->fh) {
174+
$this->client->getLogger()->error(
175+
'Failed to open file during lock acquisition',
176+
array('file' => $storageFile)
177+
);
178+
return false;
179+
}
173180
$count = 0;
174181
while (!flock($this->fh, $type | LOCK_NB)) {
175182
// Sleep for 10ms.

0 commit comments

Comments
 (0)