aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon L <szaimen@e.mail.de>2023-11-03 11:47:12 +0100
committerSimon L <szaimen@e.mail.de>2023-11-05 18:38:04 +0100
commit0e768fadfc473d58f13a34a972c755a583de2e0a (patch)
treeb6ece0baf2ea8a29c58b0070ceec59fef6334451
parentbdc520769ca72a2c5e2898d9c76429dc4d5159f0 (diff)
downloadnextcloud-server-0e768fadfc473d58f13a34a972c755a583de2e0a.tar.gz
nextcloud-server-0e768fadfc473d58f13a34a972c755a583de2e0a.zip
fix semaphore unguarding
Signed-off-by: Simon L <szaimen@e.mail.de>
-rw-r--r--build/psalm-baseline.xml7
-rw-r--r--lib/private/Preview/Generator.php8
2 files changed, 4 insertions, 11 deletions
diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml
index 23021eb80b8..fae69bf6fa0 100644
--- a/build/psalm-baseline.xml
+++ b/build/psalm-baseline.xml
@@ -3164,15 +3164,8 @@
<file src="lib/private/Preview/Generator.php">
<InvalidArgument>
<code>$maxPreviewImage</code>
- <code>$semId</code>
<code>IPreview::EVENT</code>
</InvalidArgument>
- <InvalidReturnStatement>
- <code>$sem</code>
- </InvalidReturnStatement>
- <InvalidReturnType>
- <code>false|resource</code>
- </InvalidReturnType>
<MismatchingDocblockParamType>
<code>ISimpleFile</code>
</MismatchingDocblockParamType>
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index d75d9c84cd2..c83cdb96e27 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -227,7 +227,7 @@ class Generator {
*
* @param int $semId
* @param int $concurrency
- * @return false|resource the semaphore on success or false on failure
+ * @return false|\SysvSemaphore the semaphore on success or false on failure
*/
public static function guardWithSemaphore(int $semId, int $concurrency) {
if (!extension_loaded('sysvsem')) {
@@ -246,11 +246,11 @@ class Generator {
/**
* Releases the semaphore acquired from {@see Generator::guardWithSemaphore()}.
*
- * @param resource|bool $semId the semaphore identifier returned by guardWithSemaphore
+ * @param false|\SysvSemaphore $semId the semaphore identifier returned by guardWithSemaphore
* @return bool
*/
- public static function unguardWithSemaphore($semId): bool {
- if (!is_resource($semId) || !extension_loaded('sysvsem')) {
+ public static function unguardWithSemaphore(false|\SysvSemaphore $semId): bool {
+ if ($semId === false || !($semId instanceof \SysvSemaphore)) {
return false;
}
return sem_release($semId);