Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix ShutdownScheduler: if some events are triggered defered during an…
Browse files Browse the repository at this point in the history
… already defered callback, they can be ignored.
  • Loading branch information
cdujeu committed Jun 2, 2016
1 parent 41a6949 commit 8086b00
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
3 changes: 3 additions & 0 deletions core/src/core/src/pydio/Core/Controller/Controller.php
Expand Up @@ -344,6 +344,9 @@ public static function applyActionInBackground($currentRepositoryId, $actionName
}

$repoObject = ConfService::getRepository();
if(empty($repoObject)){
$repoObject = ConfService::getRepositoryById($currentRepositoryId);
}
$clearEnv = false;
if($repoObject->getOption("USE_SESSION_CREDENTIALS")){
$encodedCreds = AJXP_Safe::getEncodedCredentialString();
Expand Down
44 changes: 26 additions & 18 deletions core/src/core/src/pydio/Core/Controller/ShutdownScheduler.php
Expand Up @@ -84,24 +84,32 @@ public function registerShutdownEvent()
$this->callbacks[] = $callback;
return true;
}
public function callRegisteredShutdown()
{
session_write_close();

public function callRegisteredShutdown()
{
session_write_close();
if (!headers_sent()) {
$size = ob_get_length();
header("Connection: close\r\n");
//header("Content-Encoding: none\r\n");
header("Content-Length: $size");
}
$size = ob_get_length();
header("Connection: close\r\n");
//header("Content-Encoding: none\r\n");
header("Content-Length: $size");
}
ob_end_flush();
flush();
foreach ($this->callbacks as $arguments) {
$callback = array_shift($arguments);
try {
call_user_func_array($callback, $arguments);
} catch (\Exception $e) {
AJXP_Logger::error(__CLASS__, __FUNCTION__, array("context"=>"Applying hook ".get_class($callback[0])."::".$callback[1], "message" => $e->getMessage()));
}
}
}
flush();
$index = 0;
while (count($this->callbacks)) {
$arguments = array_shift($this->callbacks);
$callback = array_shift($arguments);
try {
call_user_func_array($callback, $arguments);
} catch (\Exception $e) {
AJXP_Logger::error(__CLASS__, __FUNCTION__, array("context" => "Applying hook " . get_class($callback[0]) . "::" . $callback[1], "message" => $e->getMessage()));
}
$index++;
if($index > 200) {
AJXP_Logger::error(__CLASS__, __FUNCTION__, "Breaking ShutdownScheduler loop, seems too big (200)");
break;
}
}
}
}

0 comments on commit 8086b00

Please sign in to comment.