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 multi-threaded 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 implemented 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 separate process php-cgi.exe. So the assumption for this warning even will not occur.
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) ?