flock() implemented at the process level

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.
On http://php.net/manual/en/function.flock.php is written a warning:

" On some operating systems *flock()* is implemented at the process level. When using a multithreaded server API like ISAPI you may not be able to rely on *flock()* to protect files against other PHP scripts running in parallel threads of the same server instance! ... "

I do not understand what means that flock is implmented at the process level.
Does it mean following?:
If in one process in one thread is called flock($fp, LOCK_EX) , in the second thread flock($fp, LOCK_EX) won't block. $fp are the same in both calls and flock(.) in the second thread is called before flock(., LOCK_UN) from the first thread.

I made a test on Windows 2008 R2, ISS, php 5.3 FastCGI.
I tried even 4 concurrent requests and I think it is working (flock blocks as expected). I found out that for each GET request it was created a seperate process php-cgi.exe. So the assumption for this warning even will not occure.

I made a second test on Windows 2008 R2, Apache, php 5.3 as a module.
In this scenario flock also works. And all GET requests were handled by the same process.

Can someone confirm that it is safe to use flock on Windows/IIS+FastCGI and Windows/Apache(multithread)+php(module) ?

Jan.




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux