mirror of
https://github.com/berkeleydb/libdb.git
synced 2024-11-17 01:26:25 +00:00
364 lines
14 KiB
HTML
364 lines
14 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|||
|
<head>
|
|||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|||
|
<title>DbEnv::lock_get()</title>
|
|||
|
<link rel="stylesheet" href="apiReference.css" type="text/css" />
|
|||
|
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
|
|||
|
<link rel="start" href="index.html" title="Berkeley DB C++ API Reference" />
|
|||
|
<link rel="up" href="lock.html" title="Chapter 7. The DbLock Handle" />
|
|||
|
<link rel="prev" href="lockdetect.html" title="DbEnv::lock_detect()" />
|
|||
|
<link rel="next" href="lockid.html" title="DbEnv::lock_id()" />
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<div xmlns="" class="navheader">
|
|||
|
<div class="libver">
|
|||
|
<p>Library Version 11.2.5.2</p>
|
|||
|
</div>
|
|||
|
<table width="100%" summary="Navigation header">
|
|||
|
<tr>
|
|||
|
<th colspan="3" align="center">DbEnv::lock_get()</th>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td width="20%" align="left"><a accesskey="p" href="lockdetect.html">Prev</a> </td>
|
|||
|
<th width="60%" align="center">Chapter 7.
|
|||
|
The DbLock Handle
|
|||
|
</th>
|
|||
|
<td width="20%" align="right"> <a accesskey="n" href="lockid.html">Next</a></td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<hr />
|
|||
|
</div>
|
|||
|
<div class="sect1" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h2 class="title" style="clear: both"><a id="lockget"></a>DbEnv::lock_get()</h2>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<pre class="programlisting">#include <db_cxx.h>
|
|||
|
|
|||
|
int
|
|||
|
DbEnv::lock_get(u_int32_t locker, u_int32_t flags,
|
|||
|
const Dbt *object, const db_lockmode_t lock_mode, DbLock *lock);</pre>
|
|||
|
<p>
|
|||
|
The <code class="methodname">DbEnv::lock_get()</code> method acquires a lock from the lock table,
|
|||
|
returning information about it in the <span class="bold"><strong>lock</strong></span> parameter.
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
The <code class="methodname">DbEnv::lock_get()</code> <span>
|
|||
|
|
|||
|
<span>
|
|||
|
method either returns a non-zero error value or throws an
|
|||
|
exception that encapsulates a non-zero error value on
|
|||
|
failure, and returns 0 on success.
|
|||
|
</span>
|
|||
|
</span>
|
|||
|
</p>
|
|||
|
<div class="sect2" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h3 class="title"><a id="id3633660"></a>Parameters</h3>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="sect3" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h4 class="title"><a id="id3633416"></a>locker</h4>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
The <span class="bold"><strong>locker</strong></span> parameter is an unsigned
|
|||
|
32-bit integer quantity. It represents the entity requesting the
|
|||
|
lock.
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
<div class="sect3" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h4 class="title"><a id="id3633746"></a>flags</h4>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
The <span class="bold"><strong>flags</strong></span> parameter must be set to 0
|
|||
|
or the following value:
|
|||
|
</p>
|
|||
|
<div class="itemizedlist">
|
|||
|
<ul type="disc">
|
|||
|
<li>
|
|||
|
<p><a id="get_DB_LOCK_NOWAIT"></a>
|
|||
|
<code class="literal">DB_LOCK_NOWAIT</code>
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
If a lock cannot be granted because the requested lock conflicts with
|
|||
|
an existing lock, return DB_LOCK_NOTGRANTED immediately instead of
|
|||
|
waiting for the lock to become available.
|
|||
|
</p>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="sect3" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h4 class="title"><a id="id3634119"></a>object</h4>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
The <span class="bold"><strong>object</strong></span> parameter is an untyped
|
|||
|
byte string that specifies the object to be locked. Applications
|
|||
|
using the locking subsystem directly while also doing locking via the
|
|||
|
Berkeley DB access methods must take care not to inadvertently lock
|
|||
|
objects that happen to be equal to the unique file IDs used to lock
|
|||
|
files. See <a href="../../programmer_reference/lock_am_conv.html" class="olink">Access method
|
|||
|
locking conventions</a> in the <em class="citetitle">Berkeley DB Programmer's Reference Guide</em>
|
|||
|
for more information.
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
<div class="sect3" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h4 class="title"><a id="id3634123"></a>lock_mode</h4>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
The <span class="bold"><strong>lock_mode</strong></span> parameter is used as an
|
|||
|
index into the environment's lock conflict matrix. When using the
|
|||
|
default lock conflict matrix, <span class="bold"><strong>lock_mode</strong></span> must be set to one of the following
|
|||
|
values:
|
|||
|
</p>
|
|||
|
<div class="itemizedlist">
|
|||
|
<ul type="disc">
|
|||
|
<li>
|
|||
|
<p>
|
|||
|
<code class="literal">DB_LOCK_READ</code>
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
read (shared)
|
|||
|
</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p>
|
|||
|
<code class="literal">DB_LOCK_WRITE</code>
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
write (exclusive)
|
|||
|
</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p>
|
|||
|
<code class="literal">DB_LOCK_IWRITE</code>
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
intention to write (shared)
|
|||
|
</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p>
|
|||
|
<code class="literal">DB_LOCK_IREAD</code>
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
intention to read (shared)
|
|||
|
</p>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p>
|
|||
|
<code class="literal">DB_LOCK_IWR</code>
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
intention to read and write (shared)
|
|||
|
</p>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
See <a class="xref" href="envset_lk_conflicts.html" title="DbEnv::set_lk_conflicts()">DbEnv::set_lk_conflicts()</a>
|
|||
|
and <a href="../../programmer_reference/lock_stdmode.html" class="olink">Standard Lock Modes</a>
|
|||
|
for more information on the lock conflict matrix.
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
<div class="sect3" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h4 class="title"><a id="id3634208"></a>lock</h4>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
The <code class="methodname">DbEnv::lock_get()</code>
|
|||
|
method returns the lock information in <span class="bold"><strong>lock</strong></span>.
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="sect2" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h3 class="title"><a id="id3634295"></a>Errors</h3>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
The <code class="methodname">DbEnv::lock_get()</code> <span>
|
|||
|
|
|||
|
<span>
|
|||
|
method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a>
|
|||
|
exception, encapsulating one of the following non-zero errors, or return one
|
|||
|
of the following non-zero errors:
|
|||
|
</span>
|
|||
|
</span>
|
|||
|
</p>
|
|||
|
<div class="sect3" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h4 class="title"><a id="id3634103"></a><span>DbDeadlockException or </span>DB_LOCK_DEADLOCK</h4>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
A transactional database environment operation was selected to resolve
|
|||
|
a deadlock.
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
<a class="xref" href="dbdeadlock.html" title="DbDeadlockException">DbDeadlockException</a> is thrown if
|
|||
|
your Berkeley DB API is configured to throw exceptions.
|
|||
|
Otherwise, <code class="literal">DB_LOCK_DEADLOCK</code> is returned.
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
<div class="sect3" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h4 class="title"><a id="id3634179"></a><span>DbLockNotGrantedException or </span>DB_LOCK_NOTGRANTED</h4>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
A Berkeley DB Concurrent Data Store database environment configured
|
|||
|
for lock timeouts was unable to grant a lock in the allowed time.
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
<a class="xref" href="dblocknotgranted.html" title="DbLockNotGrantedException">DbLockNotGrantedException</a> is thrown if
|
|||
|
your Berkeley DB API is configured to throw exceptions.
|
|||
|
Otherwise, <code class="literal">DB_LOCK_NOTGRANTED</code> is returned.
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
<div class="sect3" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h4 class="title"><a id="id3633762"></a><span>DbLockNotGrantedException or </span>DB_LOCK_NOTGRANTED</h4>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
The <a class="link" href="lockvec.html#vec_DB_LOCK_NOWAIT">DB_LOCK_NOWAIT</a>
|
|||
|
flag or lock timers were configured and the lock could not be granted
|
|||
|
before the wait-time expired.
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
<a class="xref" href="dblocknotgranted.html" title="DbLockNotGrantedException">DbLockNotGrantedException</a> is thrown if
|
|||
|
your Berkeley DB API is configured to throw exceptions.
|
|||
|
Otherwise, <code class="literal">DB_LOCK_NOTGRANTED</code> is returned.
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
<div class="sect3" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h4 class="title"><a id="id3634349"></a>EINVAL</h4>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
An invalid flag value or parameter was specified.
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
<div class="sect3" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h4 class="title"><a id="id3634489"></a>EINVAL</h4>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
The method was called on an environment which had been
|
|||
|
opened without being configured for locking.
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
<div class="sect3" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h4 class="title"><a id="id3634497"></a>ENOMEM</h4>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
The maximum number of locks has been reached.
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="sect2" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h3 class="title"><a id="id3634333"></a>Class</h3>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
<a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a>,
|
|||
|
<a class="link" href="lock.html" title="Chapter 7. The DbLock Handle">DbLock</a>
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
<div class="sect2" lang="en" xml:lang="en">
|
|||
|
<div class="titlepage">
|
|||
|
<div>
|
|||
|
<div>
|
|||
|
<h3 class="title"><a id="id3634252"></a>See Also</h3>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<p>
|
|||
|
<a class="xref" href="lock.html#locklist" title="Locking Subsystem and Related Methods">Locking Subsystem and Related Methods</a>
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="navfooter">
|
|||
|
<hr />
|
|||
|
<table width="100%" summary="Navigation footer">
|
|||
|
<tr>
|
|||
|
<td width="40%" align="left"><a accesskey="p" href="lockdetect.html">Prev</a> </td>
|
|||
|
<td width="20%" align="center">
|
|||
|
<a accesskey="u" href="lock.html">Up</a>
|
|||
|
</td>
|
|||
|
<td width="40%" align="right"> <a accesskey="n" href="lockid.html">Next</a></td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td width="40%" align="left" valign="top">DbEnv::lock_detect() </td>
|
|||
|
<td width="20%" align="center">
|
|||
|
<a accesskey="h" href="index.html">Home</a>
|
|||
|
</td>
|
|||
|
<td width="40%" align="right" valign="top"> DbEnv::lock_id()</td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
</div>
|
|||
|
</body>
|
|||
|
</html>
|