Debian Codegraph @

docs/api_reference/C/lockvec.html

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <title>DB_ENV-&gt;lock_vec()</title>
7 <link rel="stylesheet" href="apiReference.css" type="text/css" />
8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9 <link rel="start" href="index.html" title="Berkeley DB C API Reference" />
10 <link rel="up" href="lock.html" title="Chapter 6.  The DB_LOCK Handle" />
11 <link rel="prev" href="lockstat_print.html" title="DB_ENV-&gt;lock_stat_print()" />
12 <link rel="next" href="lsn.html" title="Chapter 7.  The DB_LSN Handle" />
13 </head>
14 <body>
15 <div xmlns="" class="navheader">
16 <div class="libver">
17 <p>Library Version 11.2.5.3</p>
18 </div>
19 <table width="100%" summary="Navigation header">
20 <tr>
21 <th colspan="3" align="center">DB_ENV-&gt;lock_vec()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="lockstat_print.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 6. 
26 The DB_LOCK Handle
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="lsn.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="lockvec"></a>DB_ENV-&gt;lock_vec()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db.h&gt;
42
43 int
44 DB_ENV-&gt;lock_vec(DB_ENV *env, u_int32_t locker, u_int32_t flags,
45 DB_LOCKREQ list[], int nlist, DB_LOCKREQ **elistp); </pre>
46 <p>
47 The <code class="methodname">DB_ENV-&gt;lock_vec()</code> method atomically obtains and releases one or
48 more locks from the lock table. The <code class="methodname">DB_ENV-&gt;lock_vec()</code> method is
49 intended to support acquisition or trading of multiple locks under one
50 lock table semaphore, as is needed for lock coupling or in
51 multigranularity locking for lock escalation.
52 </p>
53 <p>
54 If any of the requested locks cannot be acquired, or any of the locks
55 to be released cannot be released, the operations before the failing
56 operation are guaranteed to have completed successfully, and
57 <code class="methodname">DB_ENV-&gt;lock_vec()</code> returns a non-zero value. In addition, if
58 <span class="bold"><strong>elistp</strong></span> is not NULL, it is set to
59 point to the DB_LOCKREQ entry that was being processed when the error
60 occurred.
61 </p>
62 <p>
63 Unless otherwise specified, the <code class="methodname">DB_ENV-&gt;lock_vec()</code> <span>
64 <span>
65 method returns a non-zero error value on failure and 0 on success.
66 </span>
67
68 </span>
69 </p>
70 <div class="sect2" lang="en" xml:lang="en">
71 <div class="titlepage">
72 <div>
73 <div>
74 <h3 class="title"><a id="idp52733776"></a>Parameters</h3>
75 </div>
76 </div>
77 </div>
78 <div class="sect3" lang="en" xml:lang="en">
79 <div class="titlepage">
80 <div>
81 <div>
82 <h4 class="title"><a id="idp52750048"></a>locker</h4>
83 </div>
84 </div>
85 </div>
86 <p>
87 The <span class="bold"><strong>locker</strong></span> parameter is an unsigned
88 32-bit integer quantity. It represents the entity requesting or
89 releasing the lock.
90 </p>
91 </div>
92 <div class="sect3" lang="en" xml:lang="en">
93 <div class="titlepage">
94 <div>
95 <div>
96 <h4 class="title"><a id="idp52733136"></a>flags</h4>
97 </div>
98 </div>
99 </div>
100 <p>
101 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0
102 or the following value:
103 </p>
104 <div class="itemizedlist">
105 <ul type="disc">
106 <li>
107 <p><a id="vec_DB_LOCK_NOWAIT"></a>
108 <code class="literal">DB_LOCK_NOWAIT</code>
109 </p>
110 <p>
111 If a lock cannot be granted because the requested lock conflicts with
112 an existing lock, return DB_LOCK_NOTGRANTED immediately instead of
113 waiting for the lock to become available. In this case, if non-NULL,
114 <span class="bold"><strong>elistp</strong></span> identifies the request that
115 was not granted.
116 </p>
117 </li>
118 </ul>
119 </div>
120 </div>
121 <div class="sect3" lang="en" xml:lang="en">
122 <div class="titlepage">
123 <div>
124 <div>
125 <h4 class="title"><a id="idp52720920"></a>list</h4>
126 </div>
127 </div>
128 </div>
129 <p>
130 The <span class="bold"><strong>list</strong></span> array provided to
131 <code class="methodname">DB_ENV-&gt;lock_vec()</code> is typedef'd as DB_LOCKREQ.
132 </p>
133 <p>
134 To ensure compatibility with future releases of Berkeley DB, all
135 fields of the DB_LOCKREQ structure that are not explicitly set should
136 be initialized to 0 before the first time the structure is used. Do
137 this by declaring the structure external or static, or by calling
138 <span class="bold"><strong>memset</strong></span>(3).
139 </p>
140 <p>
141 A DB_LOCKREQ structure has at least the following fields:
142 </p>
143 <div class="itemizedlist">
144 <ul type="disc">
145 <li>
146 <p><a id="vec_op"></a>
147 <code class="literal">lockop_t op;</code>
148 </p>
149 <p>
150 The operation to be performed, which must be set to one of the
151 following values:
152 </p>
153 <div class="itemizedlist">
154 <ul type="circle">
155 <li>
156 <p><a id="vec_DB_LOCK_GET"></a>
157 <code class="literal">DB_LOCK_GET</code>
158 </p>
159 <p>
160 Get the lock defined by the values of the <span class="bold"><strong>mode</strong></span> and <span class="bold"><strong>obj</strong></span>
161 structure fields, for the specified
162 <span class="bold"><strong>locker</strong></span>.
163 Upon return from <code class="methodname">DB_ENV-&gt;lock_vec()</code>,
164 if the <span class="bold"><strong>lock</strong></span> field is non-NULL, a
165 reference to the acquired lock is stored there. (This reference is
166 invalidated by any call to <code class="methodname">DB_ENV-&gt;lock_vec()</code> or
167 <a class="xref" href="lockput.html" title="DB_ENV-&gt;lock_put()">DB_ENV-&gt;lock_put()</a> that releases
168 the lock.)
169 </p>
170 </li>
171 <li>
172 <p><a id="vec_DB_LOCK_GET_TIMEOUT"></a>
173 <code class="literal">DB_LOCK_GET_TIMEOUT</code>
174 </p>
175 <p>
176 Identical to DB_LOCK_GET except that the value in the <span class="bold"><strong>timeout</strong></span> structure field overrides any
177 previously specified timeout value for this lock. A value of 0 turns
178 off any previously specified timeout.
179 </p>
180 </li>
181 <li>
182 <p><a id="vec_DB_LOCK_PUT"></a>
183 <code class="literal">DB_LOCK_PUT</code>
184 </p>
185 <p>
186 The lock to which the <span class="bold"><strong>lock</strong></span> structure
187 field refers is released. The <span class="bold"><strong>locker</strong></span>
188 parameter, and <span class="bold"><strong>mode</strong></span> and <span class="bold"><strong>obj</strong></span> fields are ignored.
189 </p>
190 </li>
191 <li>
192 <p><a id="vec_DB_LOCK_PUT_ALL"></a>
193 <code class="literal">DB_LOCK_PUT_ALL</code>
194 </p>
195 <p>
196 All locks held by the specified <span class="bold"><strong>locker</strong></span> are released. The <span class="bold"><strong>lock</strong></span>, <span class="bold"><strong>mode</strong></span>,
197 and <span class="bold"><strong>obj</strong></span> structure fields are ignored.
198 Locks acquired in operations performed by the current call to
199 <code class="methodname">DB_ENV-&gt;lock_vec()</code> which appear before the DB_LOCK_PUT_ALL operation
200 are released; those acquired in operations appearing after the
201 DB_LOCK_PUT_ALL operation are not released.
202 </p>
203 </li>
204 <li>
205 <p><a id="vec_DB_LOCK_PUT_OBJ"></a>
206 <code class="literal">DB_LOCK_PUT_OBJ</code>
207 </p>
208 <p>
209 All locks held on <span class="bold"><strong>obj</strong></span> are released.
210 The <span class="bold"><strong>locker</strong></span> parameter and the
211 <span class="bold"><strong>lock</strong></span> and <span class="bold"><strong>mode</strong></span> structure fields are ignored. Locks
212 acquired in operations performed by the current call to
213 <code class="methodname">DB_ENV-&gt;lock_vec()</code> that appear before the DB_LOCK_PUT_OBJ operation
214 are released; those acquired in operations appearing after the
215 DB_LOCK_PUT_OBJ operation are not released.
216 </p>
217 </li>
218 <li>
219 <p><a id="vec_DB_LOCK_TIMEOUT"></a>
220 <code class="literal">DB_LOCK_TIMEOUT</code>
221 </p>
222 <p>
223 Cause the specified <span class="bold"><strong>locker</strong></span> to timeout
224 immediately. If the database environment has not configured automatic
225 deadlock detection, the transaction will timeout the next time
226 deadlock detection is performed. As transactions acquire locks on
227 behalf of a single locker ID, timing out the locker ID associated with
228 a transaction will time out the transaction itself.
229 </p>
230 </li>
231 </ul>
232 </div>
233 </li>
234 <li>
235 <p><a id="vec_lock"></a>
236 <code class="literal">DB_LOCK lock;</code>
237 </p>
238 <p>
239 A lock reference.
240 </p>
241 </li>
242 <li>
243 <p><a id="vec_mode"></a>
244 <code class="literal">const lockmode_t mode;</code>
245 </p>
246 <p>
247 The lock mode, used as an index into the environment's lock conflict
248 matrix. When using the default lock conflict matrix, <span class="bold"><strong>mode</strong></span> must be set to one of the following
249 values:
250 </p>
251 <div class="itemizedlist">
252 <ul type="circle">
253 <li>
254 <p><a id="vec_DB_LOCK_READ"></a>
255 <code class="literal">DB_LOCK_READ</code>
256 </p>
257 <p>
258 read (shared)
259 </p>
260 </li>
261 <li>
262 <p><a id="vec_DB_LOCK_WRITE"></a>
263 <code class="literal">DB_LOCK_WRITE</code>
264 </p>
265 <p>
266 write (exclusive)
267 </p>
268 </li>
269 <li>
270 <p><a id="vec_DB_LOCK_IWRITE"></a>
271 <code class="literal">DB_LOCK_IWRITE</code>
272 </p>
273 <p>
274 intention to write (shared)
275 </p>
276 </li>
277 <li>
278 <p><a id="vec_DB_LOCK_IREAD"></a>
279 <code class="literal">DB_LOCK_IREAD</code>
280 </p>
281 <p>
282 intention to read (shared)
283 </p>
284 </li>
285 <li>
286 <p><a id="vec_DB_LOCK_IWR"></a>
287 <code class="literal">DB_LOCK_IWR</code>
288 </p>
289 <p>
290 intention to read and write (shared)
291 </p>
292 </li>
293 </ul>
294 </div>
295 <p>
296 See <a class="xref" href="envset_lk_conflicts.html" title="DB_ENV-&gt;set_lk_conflicts()">DB_ENV-&gt;set_lk_conflicts()</a>
297 and <a href="../../programmer_reference/lock_stdmode.html" class="olink">Standard Lock Modes</a>
298 for more information on the lock conflict matrix.
299 </p>
300 </li>
301 <li>
302 <p>
303 <span class="bold"><a id="obj"></a><strong>const DBT obj;</strong></span>
304 </p>
305 <p>
306 An untyped byte string that specifies the object to be locked or
307 released. Applications using the locking subsystem directly while
308 also doing locking via the Berkeley DB access methods must take care
309 not to inadvertently lock objects that happen to be equal to the
310 unique file IDs used to lock files. See
311 <a href="../../programmer_reference/lock_am_conv.html" class="olink">Access method locking
312 conventions</a> in the
313 <em class="citetitle">Berkeley DB Programmer's Reference Guide</em> for more information.
314 </p>
315 </li>
316 <li>
317 <p>
318 <span class="bold"><strong>u_int32_t timeout;</strong></span>
319 </p>
320 <p>
321 The lock timeout value.
322 </p>
323 </li>
324 </ul>
325 </div>
326 </div>
327 <div class="sect3" lang="en" xml:lang="en">
328 <div class="titlepage">
329 <div>
330 <div>
331 <h4 class="title"><a id="idp52788232"></a>nlist</h4>
332 </div>
333 </div>
334 </div>
335 <p>
336 The <span class="bold"><strong>nlist</strong></span> parameter specifies the
337 number of elements in the <span class="bold"><strong>list</strong></span> array.
338 </p>
339 </div>
340 <div class="sect3" lang="en" xml:lang="en">
341 <div class="titlepage">
342 <div>
343 <div>
344 <h4 class="title"><a id="idp52754984"></a>elistp</h4>
345 </div>
346 </div>
347 </div>
348 <p>
349 If an error occurs, and the <span class="bold"><strong>elistp</strong></span>
350 parameter is non-NULL, it is set to point to the DB_LOCKREQ entry that
351 was being processed when the error occurred.
352 </p>
353 </div>
354 </div>
355 <div class="sect2" lang="en" xml:lang="en">
356 <div class="titlepage">
357 <div>
358 <div>
359 <h3 class="title"><a id="idp52789744"></a>Errors</h3>
360 </div>
361 </div>
362 </div>
363 <p>
364 The <code class="methodname">DB_ENV-&gt;lock_vec()</code> <span>
365 <span>
366 method may fail and return one of the following non-zero errors:
367 </span>
368
369 </span>
370 </p>
371 <div class="sect3" lang="en" xml:lang="en">
372 <div class="titlepage">
373 <div>
374 <div>
375 <h4 class="title"><a id="idp52753480"></a>DB_LOCK_DEADLOCK</h4>
376 </div>
377 </div>
378 </div>
379 <p>
380 A transactional database environment operation was selected to resolve
381 a deadlock.
382 </p>
383 </div>
384 <div class="sect3" lang="en" xml:lang="en">
385 <div class="titlepage">
386 <div>
387 <div>
388 <h4 class="title"><a id="idp52721472"></a>DB_LOCK_NOTGRANTED</h4>
389 </div>
390 </div>
391 </div>
392 <p>
393 A Berkeley DB Concurrent Data Store database environment configured
394 for lock timeouts was unable to grant a lock in the allowed time.
395 </p>
396 <p>
397 You attempted to open a database handle that is configured
398 for no waiting exclusive locking, but the exclusive lock could not be
399 immediately obtained. See
400 <a class="xref" href="dbset_lk_exclusive.html" title="DB-&gt;set_lk_exclusive()">DB-&gt;set_lk_exclusive()</a>
401 for more information.
402 </p>
403 </div>
404 <div class="sect3" lang="en" xml:lang="en">
405 <div class="titlepage">
406 <div>
407 <div>
408 <h4 class="title"><a id="idp52769296"></a>DB_LOCK_NOTGRANTED</h4>
409 </div>
410 </div>
411 </div>
412 <p>
413 The <a class="link" href="lockvec.html#vec_DB_LOCK_NOWAIT">DB_LOCK_NOWAIT</a>
414 flag or lock timers were configured and the lock could not be granted
415 before the wait-time expired.
416 </p>
417 </div>
418 <div class="sect3" lang="en" xml:lang="en">
419 <div class="titlepage">
420 <div>
421 <div>
422 <h4 class="title"><a id="idp52762616"></a>EINVAL</h4>
423 </div>
424 </div>
425 </div>
426 <p>
427 An invalid flag value or parameter was specified.
428 </p>
429 </div>
430 <div class="sect3" lang="en" xml:lang="en">
431 <div class="titlepage">
432 <div>
433 <div>
434 <h4 class="title"><a id="idp52769768"></a>ENOMEM</h4>
435 </div>
436 </div>
437 </div>
438 <p>
439 The maximum number of locks has been reached.
440 </p>
441 </div>
442 </div>
443 <div class="sect2" lang="en" xml:lang="en">
444 <div class="titlepage">
445 <div>
446 <div>
447 <h3 class="title"><a id="idp52757824"></a>Class</h3>
448 </div>
449 </div>
450 </div>
451 <p>
452 <a class="link" href="env.html" title="Chapter 5.  The DB_ENV Handle">DB_ENV</a>,
453 <a class="link" href="lock.html" title="Chapter 6.  The DB_LOCK Handle">DB_LOCK</a>
454 </p>
455 </div>
456 <div class="sect2" lang="en" xml:lang="en">
457 <div class="titlepage">
458 <div>
459 <div>
460 <h3 class="title"><a id="idp52756744"></a>See Also</h3>
461 </div>
462 </div>
463 </div>
464 <p>
465 <a class="xref" href="lock.html#locklist" title="Locking Subsystem and Related Methods">Locking Subsystem and Related Methods</a>
466 </p>
467 </div>
468 </div>
469 <div class="navfooter">
470 <hr />
471 <table width="100%" summary="Navigation footer">
472 <tr>
473 <td width="40%" align="left"><a accesskey="p" href="lockstat_print.html">Prev</a> </td>
474 <td width="20%" align="center">
475 <a accesskey="u" href="lock.html">Up</a>
476 </td>
477 <td width="40%" align="right"> <a accesskey="n" href="lsn.html">Next</a></td>
478 </tr>
479 <tr>
480 <td width="40%" align="left" valign="top">DB_ENV-&gt;lock_stat_print() </td>
481 <td width="20%" align="center">
482 <a accesskey="h" href="index.html">Home</a>
483 </td>
484 <td width="40%" align="right" valign="top"> Chapter 7. 
485 The DB_LSN Handle
486 </td>
487 </tr>
488 </table>
489 </div>
490 </body>
491 </html>