mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-15 03:17:38 +01:00
Format lock.php
This commit is contained in:
parent
c3de90075e
commit
00b05099f3
12
inc/lock.php
12
inc/lock.php
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
class Lock {
|
||||
function __construct($key) { global $config;
|
||||
function __construct($key) {
|
||||
global $config;
|
||||
if ($config['lock']['enabled'] == 'fs') {
|
||||
$key = str_replace('/', '::', $key);
|
||||
$key = str_replace("\0", '', $key);
|
||||
@ -10,7 +11,8 @@ class Lock {
|
||||
}
|
||||
|
||||
// Get a shared lock
|
||||
function get($nonblock = false) { global $config;
|
||||
function get($nonblock = false) {
|
||||
global $config;
|
||||
if ($config['lock']['enabled'] == 'fs') {
|
||||
$wouldblock = false;
|
||||
flock($this->f, LOCK_SH | ($nonblock ? LOCK_NB : 0), $wouldblock);
|
||||
@ -20,7 +22,8 @@ class Lock {
|
||||
}
|
||||
|
||||
// Get an exclusive lock
|
||||
function get_ex($nonblock = false) { global $config;
|
||||
function get_ex($nonblock = false) {
|
||||
global $config;
|
||||
if ($config['lock']['enabled'] == 'fs') {
|
||||
$wouldblock = false;
|
||||
flock($this->f, LOCK_EX | ($nonblock ? LOCK_NB : 0), $wouldblock);
|
||||
@ -30,7 +33,8 @@ class Lock {
|
||||
}
|
||||
|
||||
// Free a lock
|
||||
function free() { global $config;
|
||||
function free() {
|
||||
global $config;
|
||||
if ($config['lock']['enabled'] == 'fs') {
|
||||
flock($this->f, LOCK_UN);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user