thread_safety.html revision a5d18a56cdc1efd5e52064c76c261ab36876bf83
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Apache 2.0 Thread Safety Issues</title>
</head>
<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
vlink="#000080" alink="#FF0000">
<!--#include virtual="header.html" -->
<h1>Thread Safety</h1>
<p>When using any of the threaded mpms in Apache 2.0 it is important
that every function called from Apache be thread safe. When linking in 3rd
party extensions it can be difficult to determine whether the resulting
server will be thread safe. Casual testing generally won't tell you this
either as thread safety problems can lead to subtle race conditons that
may only show up in certain conditions under heavy load.</p>
<h1>Common 3rd Party Libraries</h1>
<p>The following is a list of common libraries that are used by 3rd party
Apache modules. You can check to see if your module is using a potentially
unsafe library by using tools such as <tt>ldd</tt> and <tt>nm</tt>. For
PHP, for example, try this:</p>
<pre>% ldd libphp4.so
<p>In addition to these libraries you will need to have a look at any libraries
linked statically into the module. You can use <tt>nm</tt> to look for
individual symbols in the module.</p>
<h2>Library List</h2>
<p>Please drop a note to dev@httpd.apache.org if you have additions or
corrections to this list.</p>
<table>
<tr>
<th>Library</th>
<th>Version</th>
<th>Thread Safe?</th>
<th>Notes</th>
</tr>
<tr>
<td></td>
<td>?</td>
<td></td>
</tr>
<tr>
<td>Yes</td>
<td>Be careful about sharing a connection across threads.</td>
</tr>
<tr>
<td> </td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td></td>
<td>Yes</td>
<td>Need a separate parser instance per thread</td>
</tr>
<tr>
<td> </td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>No</td>
<td>Errors returned via a static gdbm_error variable</td>
</tr>
<tr>
<td> </td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td>v6b</td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td>0.2a</td>
<td>?</td>
<td> </td>
</tr>
<tr>
<td>?</td>
<td> </td>
</tr>
<tr>
<td>?</td>
<td> </td>
</tr>
<tr>
<td>0.96g</td>
<td>Yes</td>
<td>Requires proper usage of <i>CRYPTO_num_locks</i>, <i>CRYPTO_set_locking_callback</i>, <i>CRYPTO_set_id_callback</i></td>
</tr>
<tr>
<td>?</td>
<td> </td>
</tr>
<tr>
<td>?</td>
<td> </td>
</tr>
<tr>
<td>?</td>
<td> </td>
</tr>
<tr>
<td>?</td>
<td> </td>
</tr>
<tr>
<td><a href="http://www.postgresql.org/idocs/index.php?libpq-threading.html">libpq (PostgreSQL)</a></td>
<td>Yes</td>
<td>Don't share connections across threads and watch out for crypt() calls</td>
</tr>
<tr>
<td>0.95</td>
<td>?</td>
<td></td>
</tr>
<tr>
<td>1.1.4</td>
<td>Yes</td>
<td>Relies upon thread-safe zalloc and zfree functions. Default is to use libc's calloc/free which are thread-safe.</td>
</tr>
</table>
<!--#include virtual="footer.html" -->
</body>
</html>