Skip to content

Commit

Permalink
Merge pull request #41290 from nextcloud/backport/41263/stable26
Browse files Browse the repository at this point in the history
[stable26] fix semaphore unguarding
  • Loading branch information
szaimen committed Jan 15, 2024
2 parents 85422f1 + c088709 commit 3d6b97c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 8 additions & 6 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,6 @@
</InvalidPropertyAssignmentValue>
<InvalidScalarArgument occurrences="1">
<code>0</code>
<code>0</code>
</InvalidScalarArgument>
</file>
<file src="apps/updatenotification/lib/Notification/Notifier.php">
Expand Down Expand Up @@ -1517,7 +1516,6 @@
<file src="core/routes.php">
<InvalidScope occurrences="2">
<code>$this</code>
<code>$this</code>
</InvalidScope>
</file>
<file src="core/templates/layout.public.php">
Expand Down Expand Up @@ -2173,7 +2171,6 @@
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>string</code>
<code>string</code>
</InvalidReturnType>
</file>
<file src="lib/private/Files/Node/Folder.php">
Expand Down Expand Up @@ -2479,7 +2476,6 @@
<code>$lastChunkPos</code>
<code>$newUnencryptedSize</code>
<code>$size</code>
<code>$size</code>
<code>$sourceStorage-&gt;filemtime($sourceInternalPath)</code>
</InvalidScalarArgument>
</file>
Expand Down Expand Up @@ -2537,7 +2533,6 @@
<code>null</code>
<code>null</code>
<code>null</code>
<code>null</code>
</NullableReturnStatement>
<RedundantCondition occurrences="1">
<code>is_resource($source)</code>
Expand Down Expand Up @@ -2749,10 +2744,17 @@
</InvalidReturnStatement>
</file>
<file src="lib/private/Preview/Generator.php">
<InvalidArgument occurrences="2">
<InvalidArgument occurrences="3">
<code>$maxPreviewImage</code>
<code>$semId</code>
<code>IPreview::EVENT</code>
</InvalidArgument>
<InvalidReturnStatement occurrences="1">
<code>$sem</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>false|\SysvSemaphore</code>
</InvalidReturnType>
<MismatchingDocblockParamType occurrences="1">
<code>ISimpleFile</code>
</MismatchingDocblockParamType>
Expand Down
8 changes: 4 additions & 4 deletions lib/private/Preview/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private function getSmallImagePreview(ISimpleFolder $previewFolder, File $file,
*
* @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')) {
Expand All @@ -330,11 +330,11 @@ public static function guardWithSemaphore(int $semId, int $concurrency) {
/**
* 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);
Expand Down

0 comments on commit 3d6b97c

Please sign in to comment.