Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileMutex does not release mutex if process is killed #79

Closed
danog opened this issue Dec 8, 2023 · 1 comment
Closed

FileMutex does not release mutex if process is killed #79

danog opened this issue Dec 8, 2023 · 1 comment

Comments

@danog
Copy link
Contributor

danog commented Dec 8, 2023

<?php

use Amp\File\FileMutex;

require 'vendor/autoload.php';

$pid = pcntl_fork();

if ($pid) {
    sleep(1);
    posix_kill($pid, 9);
    var_dump("killed");

    var_dump("Trying to re-acquire lock");
    $lock = new FileMutex('/tmp/test');
    $lock->acquire();
    
    var_dump("unreachable");
} else {
    $lock = new FileMutex('/tmp/test');
    $lock->acquire();
    var_dump("Acquired lock!");
}

using flock instead of just file creation like in https://github.com/danog/MadelineProto/blob/v8/src/AsyncTools.php#L83 should fix the issue.

@trowski
Copy link
Member

trowski commented Jan 12, 2025

Fixed by #87.

@trowski trowski closed this as completed Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@trowski @danog and others