| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>MHonArc Resources: LOCKMETHOD</title> |
| 5 | </head> |
| 6 | <body> |
| 7 | <!--x-rc-nav--> |
| 8 | <table border=0><tr valign="top"> |
| 9 | <td align="left" width="50%">[Prev: <a href="lockfile.html">LOCKFILE</a>]</td><td><nobr>[<a href="../resources.html#lockmethod">Resources</a>][<a href="../mhonarc.html">TOC</a>]</nobr></td><td align="right" width="50%">[Next: <a href="locktries.html">LOCKTRIES</a>]</td></tr></table> |
| 10 | <!--/x-rc-nav--> |
| 11 | <hr> |
| 12 | <h1>LOCKMETHOD</h1> |
| 13 | |
| 14 | <!-- *************************************************************** --> |
| 15 | <hr> |
| 16 | <h2>Syntax</h2> |
| 17 | |
| 18 | <dl> |
| 19 | |
| 20 | <dt><strong>Envariable</strong></dt> |
| 21 | <dd><p> |
| 22 | <code>M2H_LOCKMETHOD=</code><var>method</var> |
| 23 | </p> |
| 24 | </dd> |
| 25 | |
| 26 | <dt><strong>Element</strong></dt> |
| 27 | <dd><p> |
| 28 | <code><LOCKMETHOD></code><br> |
| 29 | <var>method</var><br> |
| 30 | <code></LOCKMETHOD></code><br> |
| 31 | </p> |
| 32 | </dd> |
| 33 | |
| 34 | <dt><strong>Command-line Option</strong></dt> |
| 35 | <dd><p> |
| 36 | <code>-lockmethod </code><var>method</var> |
| 37 | </p> |
| 38 | </dd> |
| 39 | |
| 40 | </dl> |
| 41 | |
| 42 | <!-- *************************************************************** --> |
| 43 | <hr> |
| 44 | <h2>Description</h2> |
| 45 | |
| 46 | <p>LOCKMETHOD determines how MHonArc should lock archives to protect |
| 47 | multiple MHonArc processes modifying an archive at the same time. If |
| 48 | after reading this page you still are unsure on what method to use, or |
| 49 | do not understand some of the material, then just stick with the default |
| 50 | value. |
| 51 | </p> |
| 52 | |
| 53 | <p>The following is a list of possible values for LOCKMETHOD: |
| 54 | </p> |
| 55 | <dl> |
| 56 | |
| 57 | <dt><tt>directory</tt></dt> |
| 58 | <dd><p>MHonArc uses a directory file in the archive directory to |
| 59 | lock an archive. When MHonArc is to access/modify an archive, it |
| 60 | will first try to create a directory in the archive directory |
| 61 | with a name determined by the |
| 62 | <a href="lockfile.html">LOCKFILE</a> resource. MHonArc will try |
| 63 | <a href="locktries.html">LOCKTRIES</a> times to create |
| 64 | the directory (obtains the lock) before timing out. |
| 65 | </p> |
| 66 | </dd> |
| 67 | |
| 68 | <dt><tt>flock</tt></dt> |
| 69 | <dd><p>MHonArc will use Perl's <b>flock()</b> operator. |
| 70 | <a href="lockfile.html">LOCKFILE</a> will be created in the archive |
| 71 | directory if does not already exist. Then MHonArc will try to |
| 72 | <a href="locktries.html">LOCKTRIES</a> times to obtain |
| 73 | an exclusive lock on the file via flock() before timing out. |
| 74 | </p> |
| 75 | </dd> |
| 76 | |
| 77 | </dl> |
| 78 | |
| 79 | <table border=0 cellpadding=4> |
| 80 | <tr valign=top> |
| 81 | <td><strong><font color="red">WARNING</font></strong></td> |
| 82 | <td><p>Each locking method is incompatible with each other. Therefore, |
| 83 | make sure the same method is specified for all MHonArc processes that |
| 84 | will be accessing a given archive. |
| 85 | If you want to change the default |
| 86 | lock method so it will affect all MHonArc processes, you can set |
| 87 | it via the default resource file or through <b><tt>mhasiteinit.pl</tt></b>. |
| 88 | See |
| 89 | <a href="../install.html#postinstall">Post Installation Configuration</a> |
| 90 | for more information. |
| 91 | </p> |
| 92 | </td> |
| 93 | </tr> |
| 94 | </table> |
| 95 | |
| 96 | <p>The following sub-sections give more information of each lock method, |
| 97 | including the pros and cons of each, |
| 98 | and assumes you have some knowledge about file systems. |
| 99 | </p> |
| 100 | |
| 101 | <h3>Directory File Method</h3> |
| 102 | <p>The directory file method is the default method used by MHonArc, |
| 103 | and is the method used by past version of MHonArc. If you are familiar |
| 104 | with locking methods used by other software, you may find it strange |
| 105 | that a directory (which is just a special kind of file) is used instead |
| 106 | of a plain file. The reason a directory is used is that it has |
| 107 | unique properties over regular files on the various operating systems |
| 108 | MHonArc runs on. The property that MHonArc takes advantage of is |
| 109 | that you cannot create a new directory over an existing directory of |
| 110 | the same name. This property is not guaranteed for plain files, or |
| 111 | at least Perl cannot give a common interface for plain files to work |
| 112 | on all platforms. It may be possible to use a plain file with |
| 113 | Perl's <b>sysopen()</b> operator with the proper options, but |
| 114 | the needed sysopen() options are not guaranteed to be available |
| 115 | for all ports of Perl. |
| 116 | </p> |
| 117 | |
| 118 | <h4>Pros</h4> |
| 119 | <ul> |
| 120 | <li><p>Appears to work for all known platforms. |
| 121 | </p> |
| 122 | </li> |
| 123 | </ul> |
| 124 | <h4>Cons</h4> |
| 125 | <ul> |
| 126 | <li><p>If MHonArc/Perl abnormally terminates, MHonArc may not have the |
| 127 | chance to delete the directory, failing to release the lock on the archive |
| 128 | (a stale lock). |
| 129 | This will cause other MHonArc processes to fail out with "Unable to lock ..." |
| 130 | messages. To correct, manual deletion of the directory is required |
| 131 | (or <a href="force.html">FORCE</a> must be used). |
| 132 | </p> |
| 133 | </li> |
| 134 | </ul> |
| 135 | |
| 136 | <h3>flock Method</h3> |
| 137 | <p>Using flock() is a common method for locking files under Unix-type |
| 138 | operating systems. In order to use flock() method, the <b>Symbol</b> |
| 139 | and <b>Fcntl</b> Perl modules must be available. If not available, and |
| 140 | this method is specified, MHonArc will fallback to the directory file |
| 141 | method. |
| 142 | </p> |
| 143 | <p>Unlike the directory method, it is okay if |
| 144 | <a href="lockfile.html">LOCKFILE</a> stays around, and actually, it |
| 145 | should never be manual deleted. |
| 146 | </p> |
| 147 | |
| 148 | <h4>Pros</h4> |
| 149 | <ul> |
| 150 | <li><p>Lock is automatically released if MHonArc/Perl abnormally terminates, |
| 151 | eliminating the stale lock problem. |
| 152 | </p> |
| 153 | </li> |
| 154 | </ul> |
| 155 | <h4>Cons</h4> |
| 156 | <ul> |
| 157 | <li><p>Not availabe on all platforms. |
| 158 | </p> |
| 159 | </li> |
| 160 | <li><p>May not work over NFS reliably. Read the documentation |
| 161 | for flock() in the Perl documentation for more information. |
| 162 | </p> |
| 163 | </ul> |
| 164 | |
| 165 | <!-- *************************************************************** --> |
| 166 | <hr> |
| 167 | <h2>Default Setting</h2> |
| 168 | |
| 169 | <p><tt>directory</tt> |
| 170 | </p> |
| 171 | <table border=0 cellpadding=4> |
| 172 | <tr valign=top> |
| 173 | <td><strong>NOTE</strong></td> |
| 174 | <td><p>The use of <LOCKMETHOD> within an |
| 175 | <a href="rcfile.html">RCFILE</a> will take affect <b>ONLY</b> if used in the |
| 176 | <a href="defrcfile.html">DEFRCFILE</a>. |
| 177 | </p> |
| 178 | </td> |
| 179 | </tr> |
| 180 | </table> |
| 181 | <table border=0 cellpadding=4> |
| 182 | <tr valign=top> |
| 183 | <td><strong><font color="red">WARNING</font></strong></td> |
| 184 | <td><p>Each locking method is incompatible with each other. Therefore, |
| 185 | make sure the same method is specified for all MHonArc processes that |
| 186 | will be accessing a given archive. |
| 187 | If you want to change the default |
| 188 | lock method so it will affect all MHonArc processes, you can set |
| 189 | it via the default resource file or through <b><tt>mhasiteinit.pl</tt></b>. |
| 190 | See |
| 191 | <a href="../install.html#postinstall">Post Installation Configuration</a> |
| 192 | for more information. |
| 193 | </p> |
| 194 | </td> |
| 195 | </tr> |
| 196 | </table> |
| 197 | |
| 198 | |
| 199 | <!-- *************************************************************** --> |
| 200 | <hr> |
| 201 | <h2>Resource Variables</h2> |
| 202 | |
| 203 | <p>N/A |
| 204 | </p> |
| 205 | |
| 206 | <!-- *************************************************************** --> |
| 207 | <hr> |
| 208 | <h2>Examples</h2> |
| 209 | |
| 210 | <p>None. |
| 211 | </p> |
| 212 | |
| 213 | <!-- *************************************************************** --> |
| 214 | <hr> |
| 215 | <h2>Version</h2> |
| 216 | |
| 217 | <p>2.4.0 |
| 218 | </p> |
| 219 | |
| 220 | <!-- *************************************************************** --> |
| 221 | <hr> |
| 222 | <h2>See Also</h2> |
| 223 | |
| 224 | <p> |
| 225 | <a href="force.html">FORCE</a>, |
| 226 | <a href="lock.html">LOCK</a>, |
| 227 | <a href="lockdelay.html">LOCKDELAY</a>, |
| 228 | <a href="lockfile.html">LOCKFILE</a>, |
| 229 | <a href="locktries.html">LOCKTRIES</a> |
| 230 | </p> |
| 231 | |
| 232 | <!-- *************************************************************** --> |
| 233 | <hr> |
| 234 | <!--x-rc-nav--> |
| 235 | <table border=0><tr valign="top"> |
| 236 | <td align="left" width="50%">[Prev: <a href="lockfile.html">LOCKFILE</a>]</td><td><nobr>[<a href="../resources.html#lockmethod">Resources</a>][<a href="../mhonarc.html">TOC</a>]</nobr></td><td align="right" width="50%">[Next: <a href="locktries.html">LOCKTRIES</a>]</td></tr></table> |
| 237 | <!--/x-rc-nav--> |
| 238 | <hr> |
| 239 | <address> |
| 240 | $Date: 2002/07/27 05:13:10 $ <br> |
| 241 | <img align="top" src="../monicon.png" alt=""> |
| 242 | <a href="http://www.mhonarc.org/" |
| 243 | ><strong>MHonArc</strong></a><br> |
| 244 | Copyright © 1999, <a href="http://www.earlhood.com/" |
| 245 | >Earl Hood</a>, <a href="mailto:mhonarc@mhonarc.org" |
| 246 | >mhonarc@mhonarc.org</a><br> |
| 247 | </address> |
| 248 | |
| 249 | </body> |
| 250 | </html> |