Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/brummett/ipc-fslock

Perl module to implement shared+exclusive locks using the filesystem for IPC
https://github.com/brummett/ipc-fslock

Last synced: 1 day ago
JSON representation

Perl module to implement shared+exclusive locks using the filesystem for IPC

Awesome Lists containing this project

README

        

Lock dir structure

symlink--------> readers/ r1
r2
r3
writer1/
writer2/

Aquire lock:

do {
redo unless mkdir $lock_dir
if(readlock) {
redo unless create reader_file
}
while(1) {
return 1 if symlink
if (readlock) {
my $points_to = readlink
return 1 if $points_to =~ m/readers/
}
sleep
}

Give up lock:

if (readlock) {
unlink reader_file
}
$rv = rmdir lock_dir
if ($rv) {
unlink symlink
}
return 1