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>DbEnv::set_timeout()</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="env.html" title="Chapter 5. The DbEnv Handle" /> 11 <link rel="prev" href="envset_thread_id_string.html" title="DbEnv::set_thread_id_string()" /> 12 <link rel="next" href="envset_tmp_dir.html" title="DbEnv::set_tmp_dir()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DbEnv::set_timeout()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="envset_thread_id_string.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 5. 23 The DbEnv Handle 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="envset_tmp_dir.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="envset_timeout"></a>DbEnv::set_timeout()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41DbEnv::set_timeout(db_timeout_t timeout, u_int32_t flags); </pre> 42 <p> 43 The <code class="methodname">DbEnv::set_timeout()</code> method sets timeout values for locks or 44 transactions in the database environment, and the wait time for a process to 45 exit the environment when 46 <a class="link" href="envopen.html#envopen_DB_REGISTER">DB_REGISTER</a> 47 recovery is needed. 48 </p> 49 <p> 50 DB_SET_LOCK_TIMEOUT and DB_SET_TXN_TIMEOUT timeouts are checked whenever a 51 thread of control blocks on a lock or when deadlock detection is performed. 52 In the case of DB_SET_LOCK_TIMEOUT, the lock is one requested explicitly 53 through the Lock subsystem interfaces. In the case of DB_SET_TXN_TIMEOUT, the 54 lock is one requested on behalf of a transaction. In either case, it 55 may be a lock requested by the database access methods underlying the 56 application. These timeouts are only checked when the lock request 57 first blocks or when deadlock detection is performed, the accuracy of 58 the timeout depends on how often deadlock detection is performed. 59 </p> 60 <p> 61 Lock and transaction timeout values specified for the database environment may 62 be overridden on a per-lock or per-transaction basis. See 63 <a class="xref" href="lockvec.html" title="DbEnv::lock_vec()">DbEnv::lock_vec()</a> and 64 <a class="xref" href="txnset_timeout.html" title="DbTxn::set_timeout()">DbTxn::set_timeout()</a> for 65 more information. 66 </p> 67 <p> 68 The <code class="methodname">DbEnv::set_timeout()</code> method may be called at any time during the 69 life of the application. 70 </p> 71 <p> 72 The <code class="methodname">DbEnv::set_timeout()</code> <span> 73 74 <span> 75 method either returns a non-zero error value or throws an 76 exception that encapsulates a non-zero error value on 77 failure, and returns 0 on success. 78 </span> 79 </span> 80 </p> 81 <div class="sect2" lang="en" xml:lang="en"> 82 <div class="titlepage"> 83 <div> 84 <div> 85 <h3 class="title"><a id="id1675570"></a>Parameters</h3> 86 </div> 87 </div> 88 </div> 89 <div class="sect3" lang="en" xml:lang="en"> 90 <div class="titlepage"> 91 <div> 92 <div> 93 <h4 class="title"><a id="id1675436"></a>flags</h4> 94 </div> 95 </div> 96 </div> 97 <p> 98 The <span class="bold"><strong>flags</strong></span> parameter must be set to 99 one of the following values: 100 </p> 101 <div class="itemizedlist"> 102 <ul type="disc"> 103 <li> 104 <p><a id="set_timeout_DB_SET_LOCK_TIMEOUT"></a> 105 <code class="literal">DB_SET_LOCK_TIMEOUT</code> 106 </p> 107 <p> 108 Set the timeout value for locks in this database environment. 109 </p> 110 <p> 111 The database environment's lock timeout value may also be configured 112 using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The 113 syntax of the entry in that file is a single line with the string 114 "set_lock_timeout", one or more whitespace characters, and the lock 115 timeout value. Because the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file is 116 read when the database environment is opened, it will silently 117 overrule configuration done before that time. 118 </p> 119 <p> 120 This flag configures a database environment, not only operations performed using the specified 121 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle. 122 </p> 123 </li> 124 <li> 125 <p><a id="set_timeout_DB_SET_REG_TIMEOUT"></a> 126 <code class="literal">DB_SET_REG_TIMEOUT</code> 127 </p> 128 <p> 129 Set the timeout value on how long to wait for processes to exit the environment 130 before recovery is started when the 131 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method was called with the 132 <a class="link" href="envopen.html#envopen_DB_REGISTER">DB_REGISTER</a> 133 flag and recovery must be performed. 134 </p> 135 <p> 136 This wait timeout value may also be configured 137 using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The 138 syntax of the entry in that file is a single line with the string 139 "set_reg_timeout", one or more whitespace characters, and the wait 140 timeout value. Because the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file is 141 read when the database environment is opened, it will silently 142 overrule configuration done before that time. 143 </p> 144 <p> 145 This flag configures operations performed using the specified 146 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle. 147 </p> 148 </li> 149 <li> 150 <p><a id="set_timeout_DB_SET_TXN_TIMEOUT"></a> 151 <code class="literal">DB_SET_TXN_TIMEOUT</code> 152 </p> 153 <p> 154 Set the timeout value for transactions in this database environment. 155 </p> 156 <p> 157 The database environment's transaction timeout value may also be 158 configured using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The 159 syntax of the entry in that file is a single line with the string 160 "set_txn_timeout", one or more whitespace characters, and the 161 transaction timeout value. Because the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file is 162 read when the database environment is opened, it will silently 163 overrule configuration done before that time. 164 </p> 165 <p> 166 This flag configures a database environment, not only operations performed using the specified 167 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle. 168 </p> 169 </li> 170 </ul> 171 </div> 172 </div> 173 <div class="sect3" lang="en" xml:lang="en"> 174 <div class="titlepage"> 175 <div> 176 <div> 177 <h4 class="title"><a id="id1675835"></a>timeout</h4> 178 </div> 179 </div> 180 </div> 181 <p> 182 The <span class="bold"><strong>timeout</strong></span> parameter is the timeout value. It must 183 be specified as an unsigned 32-bit number of microseconds, limiting the maximum 184 timeout to roughly 71 minutes. 185 </p> 186 </div> 187 </div> 188 <div class="sect2" lang="en" xml:lang="en"> 189 <div class="titlepage"> 190 <div> 191 <div> 192 <h3 class="title"><a id="id1676091"></a>Errors</h3> 193 </div> 194 </div> 195 </div> 196 <p> 197 The <code class="methodname">DbEnv::set_timeout()</code> <span> 198 199 <span> 200 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 201 exception, encapsulating one of the following non-zero errors, or return one 202 of the following non-zero errors: 203 </span> 204 </span> 205 </p> 206 <div class="sect3" lang="en" xml:lang="en"> 207 <div class="titlepage"> 208 <div> 209 <div> 210 <h4 class="title"><a id="id1675876"></a>EINVAL</h4> 211 </div> 212 </div> 213 </div> 214 <p> 215 An invalid flag value or parameter was specified. 216 </p> 217 </div> 218 </div> 219 <div class="sect2" lang="en" xml:lang="en"> 220 <div class="titlepage"> 221 <div> 222 <div> 223 <h3 class="title"><a id="id1675877"></a>Class</h3> 224 </div> 225 </div> 226 </div> 227 <p> 228 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> 229 </p> 230 </div> 231 <div class="sect2" lang="en" xml:lang="en"> 232 <div class="titlepage"> 233 <div> 234 <div> 235 <h3 class="title"><a id="id1675669"></a>See Also</h3> 236 </div> 237 </div> 238 </div> 239 <p> 240 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> 241 </p> 242 </div> 243 </div> 244 <div class="navfooter"> 245 <hr /> 246 <table width="100%" summary="Navigation footer"> 247 <tr> 248 <td width="40%" align="left"><a accesskey="p" href="envset_thread_id_string.html">Prev</a> </td> 249 <td width="20%" align="center"> 250 <a accesskey="u" href="env.html">Up</a> 251 </td> 252 <td width="40%" align="right"> <a accesskey="n" href="envset_tmp_dir.html">Next</a></td> 253 </tr> 254 <tr> 255 <td width="40%" align="left" valign="top">DbEnv::set_thread_id_string() </td> 256 <td width="20%" align="center"> 257 <a accesskey="h" href="index.html">Home</a> 258 </td> 259 <td width="40%" align="right" valign="top"> DbEnv::set_tmp_dir()</td> 260 </tr> 261 </table> 262 </div> 263 </body> 264</html> 265