PHP flock() - 幕后有什么?
在与 PHP 源码搏斗了半个小时后,我放弃了。 :P 问题是 - 在 Gentoo Linux 系统上,PHP freeze() 函数调用归结为什么系统调用? 我遇到了一些问题(例如在每一个20个循环迭代中阻塞30秒之类的问题),我想知道为什么会这样是这样。
After wrestling with PHP source for a half an hour, I gave up. :P The question is - what system call does the PHP flock() function call boil down to on a Gentoo Linux system? I'm having some issues with it (like block-for-30-seconds-in-every-one-of-20-loop-iterations kind of issues) and I would like to know why that is so.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
if this prints plainfile then the call to the php function flock() is handled by php_stdiop_set_option(...) which calls flock(). Depending on whether PHP was compiled with HAVE_FLOCK or not this may be the system call flock() or a function defined in flock_compat.c which utilizes fcntl(). On my gentoo system PHP was compiled with HAVE_FLOCK.
main/streams/plain_wrapper.c @ static int php_stdiop_set_option(...):
if this prints plainfile then the call to the php function flock() is handled by php_stdiop_set_option(...) which calls flock(). Depending on whether PHP was compiled with HAVE_FLOCK or not this may be the system call flock() or a function defined in flock_compat.c which utilizes fcntl(). On my gentoo system PHP was compiled with HAVE_FLOCK.
main/streams/plain_wrapper.c @ static int php_stdiop_set_option(...):
http://www.opengroup.org/onlinepubs/009695399/functions/fcntl。 html
http://www.opengroup.org/onlinepubs/009695399/functions/fcntl.html
除非我误解了你的要求,否则 PHP 的
flock()
是对 Unix 系统函数flock()
在 Gentoo 上。 它们具有相同的语义。Unless I'm misunderstanding what you're asking, PHP's
flock()
is a call to the Unix system functionflock()
on Gentoo. They have identical semantics.您是否在联网或已安装的驱动器上使用它? 如果您遇到的是死锁,以及一些文档中的评论讨论了这一点。
flock 的文档。
Are you using it on a networked or mounted drive? I wouldn't be surprised if what you are experiencing is deadlock, and some of the comments in the documentation talk about that.
The documentation for flock.