mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-17 18:14:42 +00:00
Config - fix locking issue when already owning the lock.
In most cases we use config locking, the lock is acquired only once, in which case all works as expected. When a controller fetches a lock and passes it on to one of the core controller wrappers which then re-acquires the same lock, the default is to load the config again. Pending data in other models will be flushed in these cases, which is unexpected if we're updating the same config, but a different section. This change only executes the reload when not yet locked by this process.
This commit is contained in:
parent
3f5d7f0779
commit
ed1d8a6260
@ -414,7 +414,6 @@ class Config extends Singleton
|
||||
{
|
||||
$this->simplexml = null;
|
||||
$this->statusIsValid = false;
|
||||
|
||||
// exception handling
|
||||
if (!file_exists($this->config_file)) {
|
||||
throw new ConfigException('file not found');
|
||||
@ -781,16 +780,17 @@ class Config extends Singleton
|
||||
|
||||
/**
|
||||
* lock configuration
|
||||
* @param boolean $reload reload config from open file handle to enforce synchronicity
|
||||
* @param boolean $reload reload config from open file handle to enforce synchronicity, when not already locked
|
||||
*/
|
||||
public function lock($reload = true)
|
||||
{
|
||||
if ($this->config_file_handle !== null) {
|
||||
flock($this->config_file_handle, LOCK_EX);
|
||||
$this->statusIsLocked = true;
|
||||
if ($reload) {
|
||||
if ($reload && !$this->statusIsLocked) {
|
||||
/* Only lock when the exclusive lock wasn't ours yet. */
|
||||
$this->load();
|
||||
}
|
||||
$this->statusIsLocked = true;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user