Skip to content

Commit

Permalink
Merge pull request #67 from mrtcode/fix-concurrent-request-limiter
Browse files Browse the repository at this point in the history
Register a shutdown function for concurrent request finishing
  • Loading branch information
dstillman authored Jun 8, 2023
2 parents 17e67f4 + d421978 commit 2cf66c3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public function init($extra) {
});
}

register_shutdown_function(array($this, 'finishConcurrentRequest'));
register_shutdown_function(array($this, 'checkDBTransactionState'));
register_shutdown_function(array($this, 'logTotalRequestTime'));
register_shutdown_function(array($this, 'checkForFatalError'));
Expand Down Expand Up @@ -1164,10 +1165,6 @@ protected function redirect($url, $httpCode=302) {


protected function end() {
if (Z_RequestLimiter::isConcurrentRequestActive()) {
Z_RequestLimiter::finishConcurrentRequest();
}

if ($this->profile && $this->currentRequestTime() > $this->timeLogThreshold) {
Zotero_DB::profileEnd($this->objectLibraryID, true, $this->uri);
}
Expand Down Expand Up @@ -1388,6 +1385,11 @@ public function handleError($no, $str, $file, $line) {
$this->handleException($e);
}

public function finishConcurrentRequest() {
if (Z_RequestLimiter::isConcurrentRequestActive()) {
Z_RequestLimiter::finishConcurrentRequest();
}
}

public function checkDBTransactionState($noLog = false) {
if (Zotero_DB::transactionInProgress()) {
Expand Down

0 comments on commit 2cf66c3

Please sign in to comment.