Doc #61436 [Asn->Csd]: Missing fflush() in flock() LOCK_EX example

From: Date: Tue, 20 Mar 2012 07:58:35 +0000
Subject: Doc #61436 [Asn->Csd]: Missing fflush() in flock() LOCK_EX example
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8094@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61436&edit=1 ID: 61436 Updated by: aharvey@php.net Reported by: blewis at eatonvance dot com Summary: Missing fflush() in flock() LOCK_EX example -Status: Assigned +Status: Closed Type: Documentation Problem Package: Documentation problem Operating System: Windows 2008 PHP Version: Irrelevant Assigned To: aharvey Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2012-03-20 07:58:20] aharvey@php.net Automatic comment from SVN on behalf of aharvey Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=324378 Log: Fix doc bug #61436 (Missing fflush() in flock() LOCK_EX example). ------------------------------------------------------------------------ [2012-03-20 07:27:57] aharvey@php.net That is a really good point. ------------------------------------------------------------------------ [2012-03-19 14:41:54] blewis at eatonvance dot com Description: ------------ --- From manual page: http://www.php.net/function.flock#refsect1-function.flock- examples --- Example should be modified to add fflush() as below. There is no point in gaining an exclusive lock if you release it before flushing output. <?php $fp = fopen("/tmp/lock.txt", "r+"); if (flock($fp, LOCK_EX)) { // do an exclusive lock ftruncate($fp, 0); // truncate file fwrite($fp, "Write something here\n"); fflush($fp); // flush output before releasing lock flock($fp, LOCK_UN); // release the lock } else { echo "Couldn't get the lock!"; } fclose($fp); ?> Actual result: -------------- Saw a corrupted file that seems to indicate that output is not automatically flushed when an exclusive lock is released. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61436&edit=1

« previous php.doc.bugs (#8094) next »