mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-17 12:22:42 +01:00
Disconnect rate limits in the PhabricatorStartup shutdown handler
This makes counts more accurate, particularly for connection limits.
This commit is contained in:
parent
c5e8de9450
commit
0e645b8f11
1 changed files with 9 additions and 0 deletions
|
@ -150,6 +150,11 @@ final class PhabricatorStartup {
|
|||
* @task hook
|
||||
*/
|
||||
public static function didShutdown() {
|
||||
// Disconnect any active rate limits before we shut down. If we don't do
|
||||
// this, requests which exit early will lock a slot in any active
|
||||
// connection limits, and won't count for rate limits.
|
||||
self::disconnectRateLimits(array());
|
||||
|
||||
$event = error_get_last();
|
||||
|
||||
if (!$event) {
|
||||
|
@ -730,6 +735,10 @@ final class PhabricatorStartup {
|
|||
public static function disconnectRateLimits(array $request_state) {
|
||||
$limits = self::$limits;
|
||||
|
||||
// Remove all limits before disconnecting them so this works properly if
|
||||
// it runs twice. (We run this automatically as a shutdown handler.)
|
||||
self::$limits = array();
|
||||
|
||||
foreach ($limits as $limit) {
|
||||
$limit->didDisconnect($request_state);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue