1<!--$Id: lock_detect.so,v 10.50 2006/12/13 17:57:23 bostic Exp $-->
2<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
3<!--See the file LICENSE for redistribution information.-->
4<html>
5<head>
6<title>Berkeley DB: DB_ENV-&gt;lock_detect</title>
7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
9</head>
10<body bgcolor=white>
11<table width="100%"><tr valign=top>
12<td>
13<b>DB_ENV-&gt;lock_detect</b>
14</td>
15<td align=right>
16<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a>
17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
18</tr></table>
19<hr size=1 noshade>
20<tt>
21<b><pre>
22#include &lt;db.h&gt;
23<p>
24int
25DB_ENV-&gt;lock_detect(DB_ENV *env,
26    u_int32_t flags, u_int32_t atype, int *rejected);
27</pre></b>
28<hr size=1 noshade>
29<b>Description: DB_ENV-&gt;lock_detect</b>
30<p>The DB_ENV-&gt;lock_detect method runs one iteration of the deadlock detector.
31The deadlock detector traverses the lock table and marks one of the
32participating lock requesters for rejection in each deadlock it finds.</p>
33<p>The DB_ENV-&gt;lock_detect method is the underlying method used by the <a href="../utility/db_deadlock.html">db_deadlock</a> utility.
34See the <a href="../utility/db_deadlock.html">db_deadlock</a> utility source code for an example of using DB_ENV-&gt;lock_detect
35in a IEEE/ANSI Std 1003.1 (POSIX) environment.</p>
36<p>The DB_ENV-&gt;lock_detect method
37returns a non-zero error value on failure
38and 0 on success.
39</p>
40<b>Parameters</b> <br>
41 <b>rejected</b><ul compact><li>If the <b>rejected</b> parameter is non-NULL, the memory location to
42which it refers will be set to the number of lock requests that were
43rejected.</ul>
44 <b>atype</b><ul compact><li>The <b>atype</b> parameter specifies which lock request(s) to reject.
45It must be set to one of the following list:
46<br>
47<b><a name="DB_LOCK_DEFAULT">DB_LOCK_DEFAULT</a></b><ul compact><li>Use whatever lock policy was specified when the database environment
48was created.  If no lock policy has yet been specified, set the lock
49policy to DB_LOCK_RANDOM.</ul>
50<b><a name="DB_LOCK_EXPIRE">DB_LOCK_EXPIRE</a></b><ul compact><li>Reject lock requests which have timed out.  No other deadlock detection
51is performed.</ul>
52<b><a name="DB_LOCK_MAXLOCKS">DB_LOCK_MAXLOCKS</a></b><ul compact><li>Reject the lock request for the locker ID with the most locks.</ul>
53<b><a name="DB_LOCK_MAXWRITE">DB_LOCK_MAXWRITE</a></b><ul compact><li>Reject the lock request for the locker ID with the most write locks.</ul>
54<b><a name="DB_LOCK_MINLOCKS">DB_LOCK_MINLOCKS</a></b><ul compact><li>Reject the lock request for the locker ID with the fewest locks.</ul>
55<b><a name="DB_LOCK_MINWRITE">DB_LOCK_MINWRITE</a></b><ul compact><li>Reject the lock request for the locker ID with the fewest write locks.</ul>
56<b><a name="DB_LOCK_OLDEST">DB_LOCK_OLDEST</a></b><ul compact><li>Reject the lock request for the locker ID with the oldest lock.</ul>
57<b><a name="DB_LOCK_RANDOM">DB_LOCK_RANDOM</a></b><ul compact><li>Reject the lock request for a random locker ID.</ul>
58<b><a name="DB_LOCK_YOUNGEST">DB_LOCK_YOUNGEST</a></b><ul compact><li>Reject the lock request for the locker ID with the youngest lock.</ul>
59<br></ul>
60 <b>flags</b><ul compact><li>The <b>flags</b> parameter is currently unused, and must be set to 0.</ul>
61<br>
62<br><b>Errors</b>
63<p>The DB_ENV-&gt;lock_detect method
64may fail and return one of the following non-zero errors:</p>
65<br>
66<b>EINVAL</b><ul compact><li>An
67invalid flag value or parameter was specified.</ul>
68<br>
69<hr size=1 noshade>
70<br><b>Class</b>
71<a href="../api_c/env_class.html">DB_ENV</a>, <a href="../api_c/lock_class.html">DB_LOCK</a>
72<br><b>See Also</b>
73<a href="../api_c/lock_list.html">Locking Subsystem and Related Methods</a>
74</tt>
75<table width="100%"><tr><td><br></td><td align=right>
76<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
77</td></tr></table>
78<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
79</body>
80</html>
81