reference/filesystem/functions/flock.xml
0bfb0eb957e0468912af86bba09fae588010c1df
...
...
@@ -1,6 +1,6 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.flock">
3
+
<refentry xml:id="function.flock" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>flock</refname>
6
6
<refpurpose>Portable advisory file locking</refpurpose>
...
...
@@ -10,9 +10,9 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>bool</type><methodname>flock</methodname>
13
-
<methodparam><type>resource</type><parameter>handle</parameter></methodparam>
13
+
<methodparam><type>resource</type><parameter>stream</parameter></methodparam>
14
14
<methodparam><type>int</type><parameter>operation</parameter></methodparam>
15
-
<methodparam choice="opt"><type>int</type><parameter role="reference">wouldblock</parameter></methodparam>
15
+
<methodparam choice="opt"><type>int</type><parameter role="reference">would_block</parameter><initializer>&null;</initializer></methodparam>
16
16
</methodsynopsis>
17
17
<para>
18
18
<function>flock</function> allows you to perform a simple reader/writer
...
...
@@ -20,9 +20,8 @@
20
20
derivatives and even Windows).
21
21
</para>
22
22
<para>
23
-
On versions of PHP before 5.3.2, the lock is released also by
24
-
<function>fclose</function> (which is also called automatically when script
25
-
finished).
23
+
The lock is released also by <function>fclose</function>,
24
+
or when <parameter>stream</parameter> is garbage collected.
26
25
</para>
27
26
<para>
28
27
PHP supports a portable way of locking complete files in an advisory way
...
...
@@ -37,7 +36,7 @@
37
36
<para>
38
37
<variablelist>
39
38
<varlistentry>
40
-
<term><parameter>handle</parameter></term>
39
+
<term><parameter>stream</parameter></term>
41
40
<listitem>
42
41
&fs.file.pointer;
43
42
</listitem>
...
...
@@ -67,13 +66,13 @@
67
66
</para>
68
67
<para>
69
68
It is also possible to add <constant>LOCK_NB</constant> as a bitmask to one
70
-
of the above operations if you don't want <function>flock</function> to
71
-
block while locking.
69
+
of the above operations, if <function>flock</function> should not
70
+
block during the locking attempt.
72
71
</para>
73
72
</listitem>
74
73
</varlistentry>
75
74
<varlistentry>
76
-
<term><parameter>wouldblock</parameter></term>
75
+
<term><parameter>would_block</parameter></term>
77
76
<listitem>
78
77
<para>
79
78
The optional third argument is set to 1 if the lock would block
...
...
@@ -92,38 +91,6 @@
92
91
</para>
93
92
</refsect1>
94
93

95
-
<refsect1 role="changelog">
96
-
&reftitle.changelog;
97
-
<para>
98
-
<informaltable>
99
-
<tgroup cols="2">
100
-
<thead>
101
-
<row>
102
-
<entry>&Version;</entry>
103
-
<entry>&Description;</entry>
104
-
</row>
105
-
</thead>
106
-
<tbody>
107
-
<row>
108
-
<entry>5.5.22, 5.6.6</entry>
109
-
<entry>
110
-
Added support for the <parameter>wouldblock</parameter> parameter on
111
-
Windows.
112
-
</entry>
113
-
</row>
114
-
<row>
115
-
<entry>5.3.2</entry>
116
-
<entry>
117
-
The automatic unlocking when the file's resource handle is closed was
118
-
removed. Unlocking now always has to be done manually.
119
-
</entry>
120
-
</row>
121
-
</tbody>
122
-
</tgroup>
123
-
</informaltable>
124
-
</para>
125
-
</refsect1>
126
-
127
94
<refsect1 role="examples">
128
95
&reftitle.examples;
129
96
<para>
...
...
@@ -204,14 +171,14 @@ fclose($fp);
204
171
</note>
205
172
<warning>
206
173
<para>
207
-
Assigning another value to <parameter>handle</parameter> argument in
174
+
Assigning another value to <parameter>stream</parameter> argument in
208
175
subsequent code will release the lock.
209
176
</para>
210
177
</warning>
211
178
<warning>
212
179
<para>
213
180
On some operating systems <function>flock</function> is implemented at
214
-
the process level. When using a multithreaded server API like ISAPI you
181
+
the process level. When using a multithreaded server API you
215
182
may not be able to rely on <function>flock</function> to protect files
216
183
against other PHP scripts running in parallel threads of the same server
217
184
instance!
...
...
@@ -222,10 +189,15 @@ fclose($fp);
222
189
return &false; under these environments.
223
190
</para>
224
191
</warning>
192
+
<note>
193
+
<para>
194
+
On Windows, if the locking process opens the file a second time, it cannot
195
+
access the file through this second handle until it unlocks the file.
196
+
</para>
197
+
</note>
225
198
</refsect1>
226
199
227
200
</refentry>
228
-

229
201
<!-- Keep this comment at the end of the file
230
202
Local variables:
231
203
mode: sgml
232
204