8000 Various fixes by pborreli · Pull Request #119 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Various fixes #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
16 commits merged into from
Feb 27, 2011
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[HttpKernel] Removed useless else
  • Loading branch information
pborreli committed Feb 27, 2011
commit 1fcb99b936e6d735ac44183eb5c815a5009092a9
44 changes: 21 additions & 23 deletions src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,32 +456,30 @@ protected function lock(Request $request, Response $entry)

// server the stale response while there is a revalidation
return true;
} else {
// wait for the lock to be released
$wait = 0;
while (file_exists($lock) && $wait < 5000000) {
usleep($wait += 50000);
}

if ($wait < 2000000) {
// replace the current entry with the fresh one
$new = $this->lookup($request);
$entry->headers = $new->headers;
$entry->setContent($new->getContent());
$entry->setStatusCode($new->getStatusCode());
$entry->setProtocolVersion($new->getProtocolVersion());
$entry->setCookies($new->getCookies());
}

return true;
} else {
// backend is slow as hell, send a 503 response (to avoid the dog pile effect)
$entry->setStatusCode(503);
$entry->setContent('503 Service Unavailable');
$entry->headers->set('Retry-After', 10);
// wait for the lock to be released
$wait = 0;
while (file_exists($lock) && $wait < 5000000) {
usleep($wait += 50000);
}

return true;
}
if ($wait < 2000000) {
// replace the current entry with the fresh one
$new = $this->lookup($request);
$entry->headers = $new->headers;
$entry->setContent($new->getContent());
$entry->setStatusCode($new->getStatusCode());
$entry->setProtocolVersion($new->getProtocolVersion());
$entry->setCookies($new->getCookies());
} else {
// backend is slow as hell, send a 503 response (to avoid the dog pile effect)
$entry->setStatusCode(503);
$entry->setContent('503 Service Unavailable');
$entry->headers->set('Retry-After', 10);
}

return true;
}

// we have the lock, call the backend
Expand Down
14 changes: 7 additions & 7 deletions src/Symfony/Component/HttpKernel/HttpCache/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public function lock(Request $request)
$this->locks[] = $path;

return true;
} else {
return $path;
}

return $path;
}

/**
Expand Down Expand Up @@ -125,12 +125,12 @@ public function lookup(Request $request)
list($req, $headers) = $match;
if (file_exists($body = $this->getPath($headers['x-content-digest'][0]))) {
return $this->restoreResponse($headers, $body);
} else {
// TODO the metaStore referenced an entity that doesn't exist in
// the entityStore. We definitely want to return nil but we should
// also purge the entry from the meta-store when this is detected.
return null;
}

// TODO the metaStore referenced an entity that doesn't exist in
// the entityStore. We definitely want to return nil but we should
// also purge the entry from the meta-store when this is detected.
return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public function read($token)
$this->close($db);
if (isset($data[0]['data'])) {
return array($data[0]['data'], $data[0]['ip'], $data[0]['url'], $data[0]['time']);
} else {
return false;
}

return false;
}

/**
Expand Down
0