亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Confused about the exclusive lock of PHP file lock?
曾經(jīng)蠟筆沒有小新
曾經(jīng)蠟筆沒有小新 2017-05-16 13:15:13
0
1
785

flock.php
<?php

$fp=fopen('lock.txt','a');

if (flock($fp,LOCK_EX)){

  fwrite($fp," HHHHHHHHHHHHHH".time()."\r\n");

}

?>
flock2.php
<?php

$fp=fopen('lock.txt','a');

if (flock($fp,LOCK_EX)){

  fwrite($fp," GGGGGGGGGGGGGG".time()."\r\n");

}

?>
Doubt:
Why is the flock.php file locked with an exclusive lock, but the lock is not released and the fclose file is not closed. But when executing flock2.php file, it can still be written.
Isn’t the exclusive lock of the file lock unable to be written by other processes after it is locked? Can I write again only when the lock is released?

曾經(jīng)蠟筆沒有小新
曾經(jīng)蠟筆沒有小新

reply all(1)
大家講道理

php is over after execution and the resources are released, and the lock will be released naturally

If you want to test, add an infinite loop to flock.php to ensure it never exits, and then execute flock2.php to see the effect

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template