note 106588 added to function.dba-open
| From: | mail{at}thorben | Date: | Mon, 21 Nov 2011 09:39:56 +0000 |
| Subject: | note 106588 added to function.dba-open | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184592@lists.php.net to get a copy of this message | ||
The other day i was struggeling with some strange behaviour, of two concurrently running scripts,
that i want to share here. I am omitting most of the error handling for brevity.
script1:
$h = dba_open("file_a", 'r', 'gdbm');
while (true)
{
dba_fetch("somekey", $h);
sleep(1);
}
dba_close($h);
______________________
script2:
// while script1 is running until eternity...
$ok = rename("file_a", "file_b");
if (! $ok)
echo "Could not move\n";
else
echo "I like to move it, move it!\n";
// GOAL: Manipulate the file only if it is not opened for reading...
RESULT:
I like to move it, move it!
So you can very well rename a file, while it is opened. The lookup in script1 is still working.
Manipulating the file in script2 will fail, as there is still an gdbm lock on the file from script1.
----
Server IP: 212.124.37.9
Probable Submitter: 194.25.133.14
----
Manual Page -- http://www.php.net/manual/en/function.dba-open.php
Edit -- https://master.php.net/note/edit/106588
Del: integrated -- https://master.php.net/note/delete/106588/integrated
Del: useless -- https://master.php.net/note/delete/106588/useless
Del: bad code -- https://master.php.net/note/delete/106588/bad+code
Del: spam -- https://master.php.net/note/delete/106588/spam
Del: non-english -- https://master.php.net/note/delete/106588/non-english
Del: in docs -- https://master.php.net/note/delete/106588/in+docs
Del: other reasons-- https://master.php.net/note/delete/106588
Reject -- https://master.php.net/note/reject/106588
Search -- https://master.php.net/manage/user-notes.php