Use TLS for the PyThreadState pointer instead of a field on Connection; this allows a Connection to be used safely in multiple threads concurrently
diff --git a/src/ssl/ssl.c b/src/ssl/ssl.c
index 7f58771..1f8cbcc 100644
--- a/src/ssl/ssl.c
+++ b/src/ssl/ssl.c
@@ -32,6 +32,8 @@
 
 void **crypto_API;
 
+int _pyOpenSSL_tstate_key;
+
 /* Exceptions defined by the SSL submodule */
 PyObject *ssl_Error,                   /* Base class              */
          *ssl_ZeroReturnError,         /* Used with SSL_get_error */
@@ -201,6 +203,13 @@
     if (!init_ssl_connection(dict))
         goto error;
 
-error:
+#ifdef WITH_THREAD
+    /*
+     * Initialize this module's threading support structures.
+     */
+    _pyOpenSSL_tstate_key = PyThread_create_key();
+#endif
+
+  error:
     ;
 }