Skip to content

Commit 2cf66c3

Browse files
authored
Merge pull request #67 from mrtcode/fix-concurrent-request-limiter
Register a shutdown function for concurrent request finishing
2 parents 17e67f4 + d421978 commit 2cf66c3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

controllers/ApiController.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public function init($extra) {
9999
});
100100
}
101101

102+
register_shutdown_function(array($this, 'finishConcurrentRequest'));
102103
register_shutdown_function(array($this, 'checkDBTransactionState'));
103104
register_shutdown_function(array($this, 'logTotalRequestTime'));
104105
register_shutdown_function(array($this, 'checkForFatalError'));
@@ -1164,10 +1165,6 @@ protected function redirect($url, $httpCode=302) {
11641165

11651166

11661167
protected function end() {
1167-
if (Z_RequestLimiter::isConcurrentRequestActive()) {
1168-
Z_RequestLimiter::finishConcurrentRequest();
1169-
}
1170-
11711168
if ($this->profile && $this->currentRequestTime() > $this->timeLogThreshold) {
11721169
Zotero_DB::profileEnd($this->objectLibraryID, true, $this->uri);
11731170
}
@@ -1388,6 +1385,11 @@ public function handleError($no, $str, $file, $line) {
13881385
$this->handleException($e);
13891386
}
13901387

1388+
public function finishConcurrentRequest() {
1389+
if (Z_RequestLimiter::isConcurrentRequestActive()) {
1390+
Z_RequestLimiter::finishConcurrentRequest();
1391+
}
1392+
}
13911393

13921394
public function checkDBTransactionState($noLog = false) {
13931395
if (Zotero_DB::transactionInProgress()) {

0 commit comments

Comments
 (0)