Regenerate the documentation
diff --git a/doc/html/building.html b/doc/html/building.html
index 8b4cb5d..5cf7429 100644
--- a/doc/html/building.html
+++ b/doc/html/building.html
@@ -62,9 +62,9 @@
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
<UL CLASS="ChildLinks">
-<LI><A NAME="tex2html78"
+<LI><A NAME="tex2html77"
href="building-unix.html">2.1 Building the Module on a Unix System </A>
-<LI><A NAME="tex2html79"
+<LI><A NAME="tex2html78"
href="building-windows.html">2.2 Building the Module on a Windows System </A>
</UL>
<!--End of Table of Child-Links-->
diff --git a/doc/html/callbacks.html b/doc/html/callbacks.html
index 9a9aeaf..7e5494f 100644
--- a/doc/html/callbacks.html
+++ b/doc/html/callbacks.html
@@ -54,9 +54,9 @@
is needed. Another problem is thread support. A lot of the OpenSSL I/O
functions can block if the socket is in blocking mode, and then you want other
Python threads to be able to do other things. The real trouble is if you've
-released the thread lock to do a potentially blocking operation, and the
-operation calls a callback. Then we must take the thread lock back<A NAME="tex2html5"
- HREF="#foot972"><SUP>4</SUP></A>.
+released the global CPython interpreter lock to do a potentially blocking
+operation, and the operation calls a callback. Then we must take the GIL back,
+since calling Python APIs without holding it is not allowed.
<P>
There are two solutions to the first problem, both of which are necessary. The
@@ -71,27 +71,20 @@
easily find the Python callback.
<P>
-The other problem is also partially solved by app_data. Since we're associating
-our wrapper objects with the ''real'' objects, we can easily access data from
-the <tt class="class">Connection</tt> object. The solution then is to simply include a
-<tt class="ctype">PyThreadState</tt> variable in the <tt class="class">Connection</tt> declaration, and write
-macros similar to <tt class="cfunction">Py_BEGIN_ALLOW_THREADS</tt> and
-<tt class="cfunction">Py_END_ALLOW_THREADS</tt> that allows specifying of the
-<tt class="ctype">PyThreadState</tt> variable to use. Now we can simply ''begin allow
-threads'' before a potentially blocking operation, and ''end allow threads''
-before calling a callback.
+The other problem is solved using thread local variables. Whenever the GIL is
+released before calling into an OpenSSL API, the PyThreadState pointer returned
+by <tt class="cfunction">PyEval_SaveState</tt> is stored in a global thread local variable
+(using Python's own TLS API, <tt class="cfunction">PyThread_set_key_value</tt>). When it is
+necessary to re-acquire the GIL, either after the OpenSSL API returns or in a C
+callback invoked by that OpenSSL API, the value of the thread local variable is
+retrieved (<tt class="cfunction">PyThread_get_key_value</tt>) and used to re-acquire the GIL.
+This allows Python threads to execute while OpenSSL APIs are running and allows
+use of any particular pyOpenSSL object from any Python thread, since there is
+no per-thread state associated with any of these objects and since OpenSSL is
+threadsafe (as long as properly initialized, as pyOpenSSL initializes it).
<P>
-<BR><HR><H4>Footnotes</H4>
-<DL>
-<DT><A NAME="foot972">... back</A><A
- href="callbacks.html#tex2html5"><SUP>4</SUP></A></DT>
-<DD>I'm
-not sure why this is necessary, but otherwise I get a segmentation violation on
-<tt class="cfunction">PyEval_CallObject</tt>
-</DD>
-</DL>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
diff --git a/doc/html/contents.html b/doc/html/contents.html
index 155b183..2953069 100644
--- a/doc/html/contents.html
+++ b/doc/html/contents.html
@@ -46,36 +46,36 @@
<!--Table of Contents-->
<UL CLASS="TofC">
-<LI><A NAME="tex2html44"
+<LI><A NAME="tex2html43"
href="intro.html">1 Introduction </A>
-<LI><A NAME="tex2html45"
+<LI><A NAME="tex2html44"
href="building.html">2 Building and Installing </A>
<UL>
-<LI><A NAME="tex2html46"
+<LI><A NAME="tex2html45"
href="building-unix.html">2.1 Building the Module on a Unix System </A>
-<LI><A NAME="tex2html47"
+<LI><A NAME="tex2html46"
href="building-windows.html">2.2 Building the Module on a Windows System </A>
</UL>
<BR>
-<LI><A NAME="tex2html48"
+<LI><A NAME="tex2html47"
href="openssl.html">3 OpenSSL -- Python interface to OpenSSL </A>
<UL>
-<LI><A NAME="tex2html49"
+<LI><A NAME="tex2html48"
href="openssl-crypto.html">3.1 crypto -- Generic cryptographic module </A>
-<LI><A NAME="tex2html50"
+<LI><A NAME="tex2html49"
href="openssl-rand.html">3.2 rand -- An interface to the OpenSSL pseudo random number generator </A>
-<LI><A NAME="tex2html51"
+<LI><A NAME="tex2html50"
href="openssl-ssl.html">3.3 SSL -- An interface to the SSL-specific parts of OpenSSL </A>
</UL>
<BR>
-<LI><A NAME="tex2html52"
+<LI><A NAME="tex2html51"
href="internals.html">4 Internals </A>
<UL>
-<LI><A NAME="tex2html53"
+<LI><A NAME="tex2html52"
href="exceptions.html">4.1 Exceptions </A>
-<LI><A NAME="tex2html54"
+<LI><A NAME="tex2html53"
href="callbacks.html">4.2 Callbacks </A>
-<LI><A NAME="tex2html55"
+<LI><A NAME="tex2html54"
href="socket-methods.html">4.3 Acessing Socket Methods </A>
</UL></UL>
<!--End of Table of Contents-->
diff --git a/doc/html/index.html b/doc/html/index.html
index 9f1246c..15d0583 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -67,68 +67,68 @@
<UL CLASS="ChildLinks">
-<LI><A NAME="tex2html9"
+<LI><A NAME="tex2html8"
href="contents.html">Contents</A>
-<LI><A NAME="tex2html10"
+<LI><A NAME="tex2html9"
href="intro.html">1 Introduction </A>
-<LI><A NAME="tex2html11"
+<LI><A NAME="tex2html10"
href="building.html">2 Building and Installing </A>
<UL>
-<LI><A NAME="tex2html12"
+<LI><A NAME="tex2html11"
href="building-unix.html">2.1 Building the Module on a Unix System </A>
-<LI><A NAME="tex2html13"
+<LI><A NAME="tex2html12"
href="building-windows.html">2.2 Building the Module on a Windows System </A>
</UL>
<BR>
-<LI><A NAME="tex2html14"
+<LI><A NAME="tex2html13"
href="openssl.html">3 <tt class="module">OpenSSL</tt> -- Python interface to OpenSSL </A>
<UL>
-<LI><A NAME="tex2html15"
+<LI><A NAME="tex2html14"
href="openssl-crypto.html">3.1 <tt class="module">crypto</tt> -- Generic cryptographic module </A>
<UL>
-<LI><A NAME="tex2html16"
+<LI><A NAME="tex2html15"
href="openssl-x509.html">3.1.1 X509 objects </A>
-<LI><A NAME="tex2html17"
+<LI><A NAME="tex2html16"
href="openssl-x509name.html">3.1.2 X509Name objects </A>
-<LI><A NAME="tex2html18"
+<LI><A NAME="tex2html17"
href="openssl-x509req.html">3.1.3 X509Req objects </A>
-<LI><A NAME="tex2html19"
+<LI><A NAME="tex2html18"
href="openssl-x509store.html">3.1.4 X509Store objects </A>
-<LI><A NAME="tex2html20"
+<LI><A NAME="tex2html19"
href="openssl-pkey.html">3.1.5 PKey objects </A>
-<LI><A NAME="tex2html21"
+<LI><A NAME="tex2html20"
href="openssl-pkcs7.html">3.1.6 PKCS7 objects </A>
-<LI><A NAME="tex2html22"
+<LI><A NAME="tex2html21"
href="openssl-pkcs12.html">3.1.7 PKCS12 objects </A>
-<LI><A NAME="tex2html23"
+<LI><A NAME="tex2html22"
href="openssl-509ext.html">3.1.8 X509Extension objects </A>
-<LI><A NAME="tex2html24"
+<LI><A NAME="tex2html23"
href="openssl-netscape-spki.html">3.1.9 NetscapeSPKI objects </A>
</UL>
-<LI><A NAME="tex2html25"
+<LI><A NAME="tex2html24"
href="openssl-rand.html">3.2 <tt class="module">rand</tt> -- An interface to the OpenSSL pseudo random number generator </A>
-<LI><A NAME="tex2html26"
+<LI><A NAME="tex2html25"
href="openssl-ssl.html">3.3 <tt class="module">SSL</tt> -- An interface to the SSL-specific parts of OpenSSL </A>
<UL>
-<LI><A NAME="tex2html27"
+<LI><A NAME="tex2html26"
href="openssl-context.html">3.3.1 Context objects </A>
-<LI><A NAME="tex2html28"
+<LI><A NAME="tex2html27"
href="openssl-connection.html">3.3.2 Connection objects </A>
</UL>
</UL>
<BR>
-<LI><A NAME="tex2html29"
+<LI><A NAME="tex2html28"
href="internals.html">4 Internals </A>
<UL>
-<LI><A NAME="tex2html30"
+<LI><A NAME="tex2html29"
href="exceptions.html">4.1 Exceptions </A>
-<LI><A NAME="tex2html31"
+<LI><A NAME="tex2html30"
href="callbacks.html">4.2 Callbacks </A>
-<LI><A NAME="tex2html32"
+<LI><A NAME="tex2html31"
href="socket-methods.html">4.3 Acessing Socket Methods </A>
</UL>
<BR>
-<LI><A NAME="tex2html33"
+<LI><A NAME="tex2html32"
href="about.html">About this document ...</A>
</UL>
<!--End of Table of Child-Links-->
diff --git a/doc/html/internals.html b/doc/html/internals.html
index 79b9c1e..5b1526a 100644
--- a/doc/html/internals.html
+++ b/doc/html/internals.html
@@ -59,11 +59,11 @@
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
<UL CLASS="ChildLinks">
-<LI><A NAME="tex2html295"
+<LI><A NAME="tex2html294"
href="exceptions.html">4.1 Exceptions </A>
-<LI><A NAME="tex2html296"
+<LI><A NAME="tex2html295"
href="callbacks.html">4.2 Callbacks </A>
-<LI><A NAME="tex2html297"
+<LI><A NAME="tex2html296"
href="socket-methods.html">4.3 Acessing Socket Methods </A>
</UL>
<!--End of Table of Child-Links-->
diff --git a/doc/html/intro.html b/doc/html/intro.html
index 9d2127b..c25a685 100644
--- a/doc/html/intro.html
+++ b/doc/html/intro.html
@@ -55,7 +55,7 @@
were also limited, though in different ways. Unfortunately, Python's standard
library SSL support has remained weak, although other packages (such as
M2Crypto<A NAME="tex2html1"
- HREF="#foot933"><SUP>1</SUP></A>)
+ HREF="#foot929"><SUP>1</SUP></A>)
have made great advances and now equal or exceed pyOpenSSL's functionality.
<P>
@@ -67,7 +67,7 @@
<P>
<BR><HR><H4>Footnotes</H4>
<DL>
-<DT><A NAME="foot933">...
+<DT><A NAME="foot929">...
M2Crypto</A><A
href="intro.html#tex2html1"><SUP>1</SUP></A></DT>
<DD>See <a class="url" href="http://chandlerproject.org/Projects/MeTooCrypto">http://chandlerproject.org/Projects/MeTooCrypto</a>
diff --git a/doc/html/openssl-crypto.html b/doc/html/openssl-crypto.html
index 6ab45a9..f55033c 100644
--- a/doc/html/openssl-crypto.html
+++ b/doc/html/openssl-crypto.html
@@ -235,23 +235,23 @@
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
<UL CLASS="ChildLinks">
-<LI><A NAME="tex2html136"
+<LI><A NAME="tex2html135"
href="openssl-x509.html">3.1.1 X509 objects </A>
-<LI><A NAME="tex2html137"
+<LI><A NAME="tex2html136"
href="openssl-x509name.html">3.1.2 X509Name objects </A>
-<LI><A NAME="tex2html138"
+<LI><A NAME="tex2html137"
href="openssl-x509req.html">3.1.3 X509Req objects </A>
-<LI><A NAME="tex2html139"
+<LI><A NAME="tex2html138"
href="openssl-x509store.html">3.1.4 X509Store objects </A>
-<LI><A NAME="tex2html140"
+<LI><A NAME="tex2html139"
href="openssl-pkey.html">3.1.5 PKey objects </A>
-<LI><A NAME="tex2html141"
+<LI><A NAME="tex2html140"
href="openssl-pkcs7.html">3.1.6 PKCS7 objects </A>
-<LI><A NAME="tex2html142"
+<LI><A NAME="tex2html141"
href="openssl-pkcs12.html">3.1.7 PKCS12 objects </A>
-<LI><A NAME="tex2html143"
+<LI><A NAME="tex2html142"
href="openssl-509ext.html">3.1.8 X509Extension objects </A>
-<LI><A NAME="tex2html144"
+<LI><A NAME="tex2html143"
href="openssl-netscape-spki.html">3.1.9 NetscapeSPKI objects </A>
</UL>
<!--End of Table of Child-Links-->
diff --git a/doc/html/openssl-rand.html b/doc/html/openssl-rand.html
index 2b03886..a478390 100644
--- a/doc/html/openssl-rand.html
+++ b/doc/html/openssl-rand.html
@@ -60,7 +60,7 @@
<dd>
Mix bytes from <var>string</var> into the PRNG state. The <var>entropy</var> argument is
(the lower bound of) an estimate of how much randomness is contained in
-<var>string</var>, measured in bytes. For more information, see e.g. <a class="rfc" name="rfcref-1852"
+<var>string</var>, measured in bytes. For more information, see e.g. <a class="rfc" name="rfcref-1845"
href="http://www.ietf.org/rfc/rfc1750.txt">RFC 1750</a>.
</dl>
@@ -68,7 +68,7 @@
<dl><dt><b><a name='l2h-90'><tt class='function'>egd</tt></a></b>(<var>path</var><big>[</big><var>, bytes</var><big>]</big>)
<dd>
Query the Entropy Gathering Daemon<A NAME="tex2html2"
- HREF="#foot954"><SUP>2</SUP></A> on socket <var>path</var> for <var>bytes</var>
+ HREF="#foot950"><SUP>2</SUP></A> on socket <var>path</var> for <var>bytes</var>
bytes of random data and and uses <tt class="function">add</tt> to seed the PRNG. The default
value of <var>bytes</var> is 255.
</dl>
@@ -110,7 +110,7 @@
<P>
<BR><HR><H4>Footnotes</H4>
<DL>
-<DT><A NAME="foot954">... Daemon</A><A
+<DT><A NAME="foot950">... Daemon</A><A
href="openssl-rand.html#tex2html2"><SUP>2</SUP></A></DT>
<DD>See
<a class="url" href="http://www.lothar.com/tech/crypto/">http://www.lothar.com/tech/crypto/</a>
diff --git a/doc/html/openssl-ssl.html b/doc/html/openssl-ssl.html
index 2e2a545..39fbb9e 100644
--- a/doc/html/openssl-ssl.html
+++ b/doc/html/openssl-ssl.html
@@ -121,7 +121,7 @@
<dd>
Factory fucnction that creates a new Connection object given an SSL context and
a socket <A NAME="tex2html4"
- HREF="#foot957"><SUP>3</SUP></A> object.
+ HREF="#foot953"><SUP>3</SUP></A> object.
</dl>
<P>
@@ -188,7 +188,7 @@
<P>
<BR><HR><H4>Footnotes</H4>
<DL>
-<DT><A NAME="foot957">... socket</A><A
+<DT><A NAME="foot953">... socket</A><A
href="openssl-ssl.html#tex2html4"><SUP>3</SUP></A></DT>
<DD>Actually, all that is required is an object that
<i>behaves</i> like a socket, you could even use files, even though it'd be
@@ -202,9 +202,9 @@
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
<UL CLASS="ChildLinks">
-<LI><A NAME="tex2html262"
+<LI><A NAME="tex2html261"
href="openssl-context.html">3.3.1 Context objects </A>
-<LI><A NAME="tex2html263"
+<LI><A NAME="tex2html262"
href="openssl-connection.html">3.3.2 Connection objects </A>
</UL>
<!--End of Table of Child-Links-->
diff --git a/doc/html/openssl.html b/doc/html/openssl.html
index 112bdb7..67a6fe7 100644
--- a/doc/html/openssl.html
+++ b/doc/html/openssl.html
@@ -80,37 +80,37 @@
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
<UL CLASS="ChildLinks">
-<LI><A NAME="tex2html111"
+<LI><A NAME="tex2html110"
href="openssl-crypto.html">3.1 <tt class="module">crypto</tt> -- Generic cryptographic module </A>
<UL>
-<LI><A NAME="tex2html112"
+<LI><A NAME="tex2html111"
href="openssl-x509.html">3.1.1 X509 objects </A>
-<LI><A NAME="tex2html113"
+<LI><A NAME="tex2html112"
href="openssl-x509name.html">3.1.2 X509Name objects </A>
-<LI><A NAME="tex2html114"
+<LI><A NAME="tex2html113"
href="openssl-x509req.html">3.1.3 X509Req objects </A>
-<LI><A NAME="tex2html115"
+<LI><A NAME="tex2html114"
href="openssl-x509store.html">3.1.4 X509Store objects </A>
-<LI><A NAME="tex2html116"
+<LI><A NAME="tex2html115"
href="openssl-pkey.html">3.1.5 PKey objects </A>
-<LI><A NAME="tex2html117"
+<LI><A NAME="tex2html116"
href="openssl-pkcs7.html">3.1.6 PKCS7 objects </A>
-<LI><A NAME="tex2html118"
+<LI><A NAME="tex2html117"
href="openssl-pkcs12.html">3.1.7 PKCS12 objects </A>
-<LI><A NAME="tex2html119"
+<LI><A NAME="tex2html118"
href="openssl-509ext.html">3.1.8 X509Extension objects </A>
-<LI><A NAME="tex2html120"
+<LI><A NAME="tex2html119"
href="openssl-netscape-spki.html">3.1.9 NetscapeSPKI objects </A>
</UL>
<BR>
-<LI><A NAME="tex2html121"
+<LI><A NAME="tex2html120"
href="openssl-rand.html">3.2 <tt class="module">rand</tt> -- An interface to the OpenSSL pseudo random number generator </A>
-<LI><A NAME="tex2html122"
+<LI><A NAME="tex2html121"
href="openssl-ssl.html">3.3 <tt class="module">SSL</tt> -- An interface to the SSL-specific parts of OpenSSL </A>
<UL>
-<LI><A NAME="tex2html123"
+<LI><A NAME="tex2html122"
href="openssl-context.html">3.3.1 Context objects </A>
-<LI><A NAME="tex2html124"
+<LI><A NAME="tex2html123"
href="openssl-connection.html">3.3.2 Connection objects </A>
</UL></UL>
<!--End of Table of Child-Links-->
diff --git a/doc/html/pyOpenSSL.how b/doc/html/pyOpenSSL.how
index 2464192..303be0d 100644
--- a/doc/html/pyOpenSSL.how
+++ b/doc/html/pyOpenSSL.how
@@ -1 +1 @@
-+++ perl /home/exarkun/Projects/pyOpenSSL/trunk/doc/tools/node2label.pl *.html
++++ perl /home/exarkun/Projects/pyOpenSSL/branches/tls-thread-safety/doc/tools/node2label.pl *.html
diff --git a/doc/html/pyOpenSSL.html b/doc/html/pyOpenSSL.html
index 9f1246c..15d0583 100644
--- a/doc/html/pyOpenSSL.html
+++ b/doc/html/pyOpenSSL.html
@@ -67,68 +67,68 @@
<UL CLASS="ChildLinks">
-<LI><A NAME="tex2html9"
+<LI><A NAME="tex2html8"
href="contents.html">Contents</A>
-<LI><A NAME="tex2html10"
+<LI><A NAME="tex2html9"
href="intro.html">1 Introduction </A>
-<LI><A NAME="tex2html11"
+<LI><A NAME="tex2html10"
href="building.html">2 Building and Installing </A>
<UL>
-<LI><A NAME="tex2html12"
+<LI><A NAME="tex2html11"
href="building-unix.html">2.1 Building the Module on a Unix System </A>
-<LI><A NAME="tex2html13"
+<LI><A NAME="tex2html12"
href="building-windows.html">2.2 Building the Module on a Windows System </A>
</UL>
<BR>
-<LI><A NAME="tex2html14"
+<LI><A NAME="tex2html13"
href="openssl.html">3 <tt class="module">OpenSSL</tt> -- Python interface to OpenSSL </A>
<UL>
-<LI><A NAME="tex2html15"
+<LI><A NAME="tex2html14"
href="openssl-crypto.html">3.1 <tt class="module">crypto</tt> -- Generic cryptographic module </A>
<UL>
-<LI><A NAME="tex2html16"
+<LI><A NAME="tex2html15"
href="openssl-x509.html">3.1.1 X509 objects </A>
-<LI><A NAME="tex2html17"
+<LI><A NAME="tex2html16"
href="openssl-x509name.html">3.1.2 X509Name objects </A>
-<LI><A NAME="tex2html18"
+<LI><A NAME="tex2html17"
href="openssl-x509req.html">3.1.3 X509Req objects </A>
-<LI><A NAME="tex2html19"
+<LI><A NAME="tex2html18"
href="openssl-x509store.html">3.1.4 X509Store objects </A>
-<LI><A NAME="tex2html20"
+<LI><A NAME="tex2html19"
href="openssl-pkey.html">3.1.5 PKey objects </A>
-<LI><A NAME="tex2html21"
+<LI><A NAME="tex2html20"
href="openssl-pkcs7.html">3.1.6 PKCS7 objects </A>
-<LI><A NAME="tex2html22"
+<LI><A NAME="tex2html21"
href="openssl-pkcs12.html">3.1.7 PKCS12 objects </A>
-<LI><A NAME="tex2html23"
+<LI><A NAME="tex2html22"
href="openssl-509ext.html">3.1.8 X509Extension objects </A>
-<LI><A NAME="tex2html24"
+<LI><A NAME="tex2html23"
href="openssl-netscape-spki.html">3.1.9 NetscapeSPKI objects </A>
</UL>
-<LI><A NAME="tex2html25"
+<LI><A NAME="tex2html24"
href="openssl-rand.html">3.2 <tt class="module">rand</tt> -- An interface to the OpenSSL pseudo random number generator </A>
-<LI><A NAME="tex2html26"
+<LI><A NAME="tex2html25"
href="openssl-ssl.html">3.3 <tt class="module">SSL</tt> -- An interface to the SSL-specific parts of OpenSSL </A>
<UL>
-<LI><A NAME="tex2html27"
+<LI><A NAME="tex2html26"
href="openssl-context.html">3.3.1 Context objects </A>
-<LI><A NAME="tex2html28"
+<LI><A NAME="tex2html27"
href="openssl-connection.html">3.3.2 Connection objects </A>
</UL>
</UL>
<BR>
-<LI><A NAME="tex2html29"
+<LI><A NAME="tex2html28"
href="internals.html">4 Internals </A>
<UL>
-<LI><A NAME="tex2html30"
+<LI><A NAME="tex2html29"
href="exceptions.html">4.1 Exceptions </A>
-<LI><A NAME="tex2html31"
+<LI><A NAME="tex2html30"
href="callbacks.html">4.2 Callbacks </A>
-<LI><A NAME="tex2html32"
+<LI><A NAME="tex2html31"
href="socket-methods.html">4.3 Acessing Socket Methods </A>
</UL>
<BR>
-<LI><A NAME="tex2html33"
+<LI><A NAME="tex2html32"
href="about.html">About this document ...</A>
</UL>
<!--End of Table of Child-Links-->