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

Open
danog opened this issue Dec 8, 2023 · 0 comments · May be fixed by #80
Open

FileMutex does not release mutex if process is killed #79

danog opened this issue Dec 8, 2023 · 0 comments · May be fixed by #80

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.

@danog danog linked a pull request Dec 9, 2023 that will close this issue
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.

2 participants
@danog and others