libdb/docs/api_reference/C/lockget.html
2012-11-14 16:35:20 -05:00

352 lines
13 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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>DB_ENV-&gt;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 6.  The DB_LOCK Handle" />
<link rel="prev" href="lockdetect.html" title="DB_ENV-&gt;lock_detect()" />
<link rel="next" href="lockid.html" title="DB_ENV-&gt;lock_id()" />
</head>
<body>
<div xmlns="" class="navheader">
<div class="libver">
<p>Library Version 11.2.5.3</p>
</div>
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">DB_ENV-&gt;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 6. 
The DB_LOCK 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>DB_ENV-&gt;lock_get()</h2>
</div>
</div>
</div>
<pre class="programlisting">#include &lt;db.h&gt;
int
DB_ENV-&gt;lock_get(DB_ENV *env, u_int32_t locker,
u_int32_t flags, const DBT *object,
const db_lockmode_t lock_mode, DB_LOCK *lock); </pre>
<p>
The <code class="methodname">DB_ENV-&gt;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">DB_ENV-&gt;lock_get()</code> <span>
<span>
method returns a non-zero error value on failure and 0 on success.
</span>
</span>
</p>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="idp60591144"></a>Parameters</h3>
</div>
</div>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="idp60539984"></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="idp60585976"></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="idp60595176"></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="idp60557752"></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="DB_ENV-&gt;set_lk_conflicts()">DB_ENV-&gt;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="idp60601152"></a>lock</h4>
</div>
</div>
</div>
<p>
The <code class="methodname">DB_ENV-&gt;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="idp60566184"></a>Errors</h3>
</div>
</div>
</div>
<p>
The <code class="methodname">DB_ENV-&gt;lock_get()</code> <span>
<span>
method may fail and 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="idp60603312"></a>DB_LOCK_DEADLOCK</h4>
</div>
</div>
</div>
<p>
A transactional database environment operation was selected to resolve
a deadlock.
</p>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="idp60601928"></a>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>
You attempted to open a database handle that is configured
for no waiting exclusive locking, but the exclusive lock could not be
immediately obtained. See
<a class="xref" href="dbset_lk_exclusive.html" title="DB-&gt;set_lk_exclusive()">DB-&gt;set_lk_exclusive()</a>
for more information.
</p>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="idp60593840"></a>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>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="idp60582584"></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="idp60613544"></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="idp60614016"></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="idp60609256"></a>Class</h3>
</div>
</div>
</div>
<p>
<a class="link" href="env.html" title="Chapter 5.  The DB_ENV Handle">DB_ENV</a>,
<a class="link" href="lock.html" title="Chapter 6.  The DB_LOCK Handle">DB_LOCK</a>
</p>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="idp60607696"></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">DB_ENV-&gt;lock_detect() </td>
<td width="20%" align="center">
<a accesskey="h" href="index.html">Home</a>
</td>
<td width="40%" align="right" valign="top"> DB_ENV-&gt;lock_id()</td>
</tr>
</table>
</div>
</body>
</html>