From 87619f8605d3778aa04425a8459b3933d3e1c24c Mon Sep 17 00:00:00 2001 From: Tim Wagner Date: Thu, 23 May 2019 11:55:00 +0200 Subject: [PATCH 1/2] Fixed concurrent session errors --- CHANGELOG.md | 10 +++ UPGRADE-1.1.22.md | 3 + build.default.properties | 2 +- .../Session/FilesystemSessionHandler.php | 65 +++++++++++++++++-- 4 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 UPGRADE-1.1.22.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ccf3ca05..55ddd2e32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# Version 1.1.22 + +## Bugfixes + +* Fixed concurrent session errors + +## Features + +* None + # Version 1.1.21 ## Bugfixes diff --git a/UPGRADE-1.1.22.md b/UPGRADE-1.1.22.md new file mode 100644 index 000000000..9ad6a4aaa --- /dev/null +++ b/UPGRADE-1.1.22.md @@ -0,0 +1,3 @@ +# Upgrade from 1.1.21 to 1.1.22 + +Updating from 1.1.21 to 1.1.22 doesn't have any impacts. Please read the apropriate UPGRADE-1.x.x files for updates from older versions to 1.1.22. \ No newline at end of file diff --git a/build.default.properties b/build.default.properties index 345ff99e3..5abb7f2e9 100644 --- a/build.default.properties +++ b/build.default.properties @@ -8,7 +8,7 @@ ;-------------------------------------------------------------------------------- ; ---- Module Release Settings -------------------------------------------------- -release.version = 1.1.21 +release.version = 1.1.22 release.name = Iron Knight ; ---- PHPCPD Settings ---------------------------------------------------------- diff --git a/src/AppserverIo/Appserver/ServletEngine/Session/FilesystemSessionHandler.php b/src/AppserverIo/Appserver/ServletEngine/Session/FilesystemSessionHandler.php index bef27d2d2..b902fa1b9 100644 --- a/src/AppserverIo/Appserver/ServletEngine/Session/FilesystemSessionHandler.php +++ b/src/AppserverIo/Appserver/ServletEngine/Session/FilesystemSessionHandler.php @@ -109,21 +109,57 @@ public function save(ServletSessionInterface $session) $marshalledSession = $this->marshall($session); // decode the session from the filesystem - $fh = fopen($sessionFilename, 'w+'); + $fh = fopen($sessionFilename, 'c'); // try to lock the session file if (flock($fh, LOCK_EX) === false) { - throw new SessionCanNotBeSavedException(sprintf('Can\'t get lock to save session data to file "%s"', $sessionFilename)); + throw new SessionCanNotBeSavedException( + sprintf( + 'Can\'t get lock to save session data to file "%s"', + $sessionFilename + ) + ); + } + + // try to truncate the session file + if (ftruncate($fh, 0) === false) { + throw new SessionCanNotBeSavedException( + sprintf( + 'Can\'t truncate session file "%s"', + $sessionFilename + ) + ); } // finally try to write the session data to the file if (fwrite($fh, $marshalledSession) === false) { - throw new SessionCanNotBeSavedException(sprintf('Session with ID "%s" can\'t be saved', $session->getId())); + throw new SessionCanNotBeSavedException( + sprintf( + 'Session with ID "%s" can\'t be saved to file "%s"', + $session->getId(), + $sessionFilename + ) + ); } // try to unlock the session file if (flock($fh, LOCK_UN) === false) { - throw new SessionCanNotBeSavedException(sprintf('Can\'t unlock session file "%s" after saving data', $sessionFilename)); + throw new SessionCanNotBeSavedException( + sprintf( + 'Can\'t unlock session file "%s" after saving data', + $sessionFilename + ) + ); + } + + // try to close the session file + if (fclose($fh) === false) { + throw new SessionCanNotBeSavedException( + sprintf( + 'Can\'t close session file "%s" after saving data', + $sessionFilename + ) + ); } } @@ -151,7 +187,12 @@ protected function unpersist($pathname) // try to lock the session file if (flock($fh, LOCK_EX) === false) { - throw new SessionDataNotReadableException(sprintf('Can\'t get lock to load session data from file "%s"', $pathname)); + throw new SessionDataNotReadableException( + sprintf( + 'Can\'t get lock to load session data from file "%s"', + $pathname + ) + ); } // read the marshalled session data from the file @@ -161,12 +202,22 @@ protected function unpersist($pathname) // try to unlock the session file if (flock($fh, LOCK_UN) === false) { - throw new SessionDataNotReadableException(sprintf('Can\'t unlock session file "%s" after reading data', $pathname)); + throw new SessionDataNotReadableException( + sprintf( + 'Can\'t unlock session file "%s" after reading data', + $pathname + ) + ); } // query whether or not the session has been unmarshalled successfully if ($marshalled === null) { - throw new SessionDataNotReadableException(sprintf('Can\'t load any session data from file %s', $pathname)); + throw new SessionDataNotReadableException( + sprintf( + 'Can\'t load any session data from file %s', + $pathname + ) + ); } // unmarshall and return the session data From c70934615f3040b87d70d4cc14996d3ddd26871e Mon Sep 17 00:00:00 2001 From: Tim Wagner Date: Thu, 23 May 2019 12:45:29 +0200 Subject: [PATCH 2/2] Update to appserver-io/ldap version 2.0.1 --- CHANGELOG.md | 1 + composer.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55ddd2e32..6ff2ea51e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Bugfixes * Fixed concurrent session errors +* Update to appserver-io/ldap version 2.0.1 ## Features diff --git a/composer.lock b/composer.lock index 3be629ecc..8a1e4eecd 100644 --- a/composer.lock +++ b/composer.lock @@ -1353,16 +1353,16 @@ }, { "name": "appserver-io/ldap", - "version": "2.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/appserver-io/ldap.git", - "reference": "8122d321021cef5a167ca334d019ad3712592df1" + "reference": "f6d5ce3577ce565d36d4e675e5f2699630d239bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appserver-io/ldap/zipball/8122d321021cef5a167ca334d019ad3712592df1", - "reference": "8122d321021cef5a167ca334d019ad3712592df1", + "url": "https://api.github.com/repos/appserver-io/ldap/zipball/f6d5ce3577ce565d36d4e675e5f2699630d239bf", + "reference": "f6d5ce3577ce565d36d4e675e5f2699630d239bf", "shasum": "" }, "require": { @@ -1370,7 +1370,7 @@ "appserver-io-psr/di": "3.0.*", "appserver-io-psr/epb": "7.0.*", "appserver-io/description": "12.0.*", - "php": ">=5.6.0 < 7.0.0" + "php": ">=5.5.0 < 7.0.0" }, "require-dev": { "appserver-io/build": "~2.0", @@ -1402,7 +1402,7 @@ "keywords": [ "ldap php application server" ], - "time": "2019-05-21T19:02:09+00:00" + "time": "2019-05-21T20:44:13+00:00" }, { "name": "appserver-io/logger",