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->set_shm_key()</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 DB_ENV Handle" /> 11 <link rel="prev" href="envset_msgfile.html" title="DB_ENV->set_msgfile()" /> 12 <link rel="next" href="envset_thread_count.html" title="DB_ENV->set_thread_count()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DB_ENV->set_shm_key()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="envset_msgfile.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��5.�� 23 The DB_ENV Handle 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="envset_thread_count.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_shm_key"></a>DB_ENV->set_shm_key()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB_ENV->set_shm_key(DB_ENV *dbenv, long shm_key); </pre> 42 <p> 43 Specify a base segment ID for Berkeley DB environment shared memory 44 regions created in system memory on VxWorks or systems supporting 45 X/Open-style shared memory interfaces; for example, UNIX systems 46 supporting <span class="bold"><strong>shmget</strong></span>(2) and related 47 System V IPC interfaces. 48 </p> 49 <p> 50 This base segment ID will be used when Berkeley DB shared memory 51 regions are first created. It will be incremented a small integer 52 value each time a new shared memory region is created; that is, if the 53 base ID is 35, the first shared memory region created will have a 54 segment ID of 35, and the next one will have a segment ID between 36 55 and 40 or so. A Berkeley DB environment always creates a master 56 shared memory region; an additional shared memory region for each of 57 the subsystems supported by the environment (Locking, Logging, Memory 58 Pool and Transaction); plus an additional shared memory region for 59 each additional memory pool cache that is supported. Already existing 60 regions with the same segment IDs will be removed. See <a href="../../programmer_reference/env_region.html" class="olink">Shared Memory Regions</a> for more 61 information. 62 </p> 63 <p> 64 The intent behind this method is two-fold: without it, applications 65 have no way to ensure that two Berkeley DB applications don't attempt 66 to use the same segment IDs when creating different Berkeley DB 67 environments. In addition, by using the same segment IDs each time 68 the environment is created, previously created segments will be 69 removed, and the set of segments on the system will not grow without 70 bound. 71 </p> 72 <p> 73 The database environment's base segment ID may also be configured 74 using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The 75 syntax of the entry in that file is a single line with the string 76 "set_shm_key", one or more whitespace characters, and the ID. Because 77 the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> 78 file is read when the database environment is opened, it will silently 79 overrule configuration done before that time. 80 </p> 81 <p> 82 The <code class="methodname">DB_ENV->set_shm_key()</code> method configures operations performed 83 using the specified <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a> handle, not all 84 operations performed on the underlying database environment. 85 </p> 86 <p> 87 The <code class="methodname">DB_ENV->set_shm_key()</code> method may not be called after the 88 <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> method is called. 89 If the database environment already exists when 90 <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> is called, the 91 information specified to <code class="methodname">DB_ENV->set_shm_key()</code> must be consistent 92 with the existing environment or corruption can occur. 93 </p> 94 <p> 95 The <code class="methodname">DB_ENV->set_shm_key()</code> <span> 96 <span> 97 method returns a non-zero error value on failure and 0 on success. 98 </span> 99 100 </span> 101 </p> 102 <div class="sect2" lang="en" xml:lang="en"> 103 <div class="titlepage"> 104 <div> 105 <div> 106 <h3 class="title"><a id="id1671092"></a>Parameters</h3> 107 </div> 108 </div> 109 </div> 110 <div class="sect3" lang="en" xml:lang="en"> 111 <div class="titlepage"> 112 <div> 113 <div> 114 <h4 class="title"><a id="id1671633"></a>shm_key</h4> 115 </div> 116 </div> 117 </div> 118 <p> 119 The <span class="bold"><strong>shm_key</strong></span> parameter is the base 120 segment ID for the database environment. 121 </p> 122 </div> 123 </div> 124 <div class="sect2" lang="en" xml:lang="en"> 125 <div class="titlepage"> 126 <div> 127 <div> 128 <h3 class="title"><a id="id1671114"></a>Errors</h3> 129 </div> 130 </div> 131 </div> 132 <p> 133 The <code class="methodname">DB_ENV->set_shm_key()</code> <span> 134 <span> 135 method may fail and return one of the following non-zero errors: 136 </span> 137 138 </span> 139 </p> 140 <div class="sect3" lang="en" xml:lang="en"> 141 <div class="titlepage"> 142 <div> 143 <div> 144 <h4 class="title"><a id="id1671701"></a>EINVAL</h4> 145 </div> 146 </div> 147 </div> 148 <p> 149 If the method was called after <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> 150 was called; or if an invalid flag value or parameter was specified. 151 </p> 152 </div> 153 </div> 154 <div class="sect2" lang="en" xml:lang="en"> 155 <div class="titlepage"> 156 <div> 157 <div> 158 <h3 class="title"><a id="id1671678"></a>Class</h3> 159 </div> 160 </div> 161 </div> 162 <p> 163 <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a> 164 </p> 165 </div> 166 <div class="sect2" lang="en" xml:lang="en"> 167 <div class="titlepage"> 168 <div> 169 <div> 170 <h3 class="title"><a id="id1671602"></a>See Also</h3> 171 </div> 172 </div> 173 </div> 174 <p> 175 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> 176 </p> 177 </div> 178 </div> 179 <div class="navfooter"> 180 <hr /> 181 <table width="100%" summary="Navigation footer"> 182 <tr> 183 <td width="40%" align="left"><a accesskey="p" href="envset_msgfile.html">Prev</a>��</td> 184 <td width="20%" align="center"> 185 <a accesskey="u" href="env.html">Up</a> 186 </td> 187 <td width="40%" align="right">��<a accesskey="n" href="envset_thread_count.html">Next</a></td> 188 </tr> 189 <tr> 190 <td width="40%" align="left" valign="top">DB_ENV->set_msgfile()��</td> 191 <td width="20%" align="center"> 192 <a accesskey="h" href="index.html">Home</a> 193 </td> 194 <td width="40%" align="right" valign="top">��DB_ENV->set_thread_count()</td> 195 </tr> 196 </table> 197 </div> 198 </body> 199</html> 200