flock() implemented at the process level

From: Date: Tue, 15 Jul 2014 14:49:42 +0000
Subject: flock() implemented at the process level
Groups: php.general 
Request: Send a blank email to php-general+get-323616@lists.php.net to get a copy of this message
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.

« previous php.general (#323616) next »