Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.4
python-m2crypto
0003-Bug-12935-0.20-started-releasing-Python-lo...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0003-Bug-12935-0.20-started-releasing-Python-locks-even-ar.diff of Package python-m2crypto
From 9fa011a27ae35425e7731341b8a4df7a875c3100 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel <ludwig.nussel@suse.de> Date: Tue, 20 Apr 2010 10:41:06 +0200 Subject: [PATCH 3/3] Bug 12935, 0.20 started releasing Python locks even around some operations that interacted with the Python runtime, potentially causing crashes and other weirdness, fix by Miloslav Trmac. git-svn-id: http://svn.osafoundation.org/m2crypto/trunk@723 2715db39-9adf-0310-9c64-84f055769b4b --- SWIG/_dsa.i | 15 ++++++++++----- SWIG/_ec.i | 9 ++++++--- SWIG/_evp.i | 9 ++++++--- SWIG/_pkcs7.i | 8 +++++--- SWIG/_rsa.i | 9 ++++++--- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/SWIG/_dsa.i b/SWIG/_dsa.i index 81e9795..a35dd88 100644 --- a/SWIG/_dsa.i +++ b/SWIG/_dsa.i @@ -155,13 +155,14 @@ PyObject *dsa_set_g(DSA *dsa, PyObject *value) { } %} -%threadallow dsa_read_params; %inline %{ DSA *dsa_read_params(BIO *f, PyObject *pyfunc) { DSA *ret; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS ret = PEM_read_bio_DSAparams(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return ret; } @@ -174,27 +175,29 @@ int dsa_write_params_bio(DSA* dsa, BIO* f) { } %} -%threadallow dsa_write_key_bio; %inline %{ int dsa_write_key_bio(DSA* dsa, BIO* f, EVP_CIPHER *cipher, PyObject *pyfunc) { int ret; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS ret = PEM_write_bio_DSAPrivateKey(f, dsa, cipher, NULL, 0, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return ret; } %} -%threadallow dsa_write_key_bio_no_cipher; %inline %{ int dsa_write_key_bio_no_cipher(DSA* dsa, BIO* f, PyObject *pyfunc) { int ret; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS ret = PEM_write_bio_DSAPrivateKey(f, dsa, NULL, NULL, 0, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return ret; } @@ -207,25 +210,27 @@ int dsa_write_pub_key_bio(DSA* dsa, BIO* f) { } %} -%threadallow dsa_read_key; %inline %{ DSA *dsa_read_key(BIO *f, PyObject *pyfunc) { DSA *ret; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS ret = PEM_read_bio_DSAPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return ret; } %} -%threadallow dsa_read_pub_key; %inline %{ DSA *dsa_read_pub_key(BIO *f, PyObject *pyfunc) { DSA *ret; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS ret = PEM_read_bio_DSA_PUBKEY(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return ret; } diff --git a/SWIG/_ec.i b/SWIG/_ec.i index a9383c1..f0e52bd 100644 --- a/SWIG/_ec.i +++ b/SWIG/_ec.i @@ -205,39 +205,42 @@ int ec_key_write_pubkey(EC_KEY *key, BIO *f) { } %} -%threadallow ec_key_read_bio; %inline %{ EC_KEY *ec_key_read_bio(BIO *f, PyObject *pyfunc) { EC_KEY *ret; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS ret = PEM_read_bio_ECPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return ret; } %} -%threadallow ec_key_write_bio; %inline %{ int ec_key_write_bio(EC_KEY *key, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { int ret; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS ret = PEM_write_bio_ECPrivateKey(f, key, cipher, NULL, 0, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return ret; } %} -%threadallow ec_key_write_bio_no_cipher; %inline %{ int ec_key_write_bio_no_cipher(EC_KEY *key, BIO *f, PyObject *pyfunc) { int ret; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS ret = PEM_write_bio_ECPrivateKey(f, key, NULL, NULL, 0, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return ret; } diff --git a/SWIG/_evp.i b/SWIG/_evp.i index d58160c..2d2189a 100644 --- a/SWIG/_evp.i +++ b/SWIG/_evp.i @@ -463,39 +463,42 @@ int verify_final(EVP_MD_CTX *ctx, PyObject *blob, EVP_PKEY *pkey) { } %} -%threadallow pkey_write_pem_no_cipher; %inline %{ int pkey_write_pem_no_cipher(EVP_PKEY *pkey, BIO *f, PyObject *pyfunc) { int ret; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS ret = PEM_write_bio_PKCS8PrivateKey(f, pkey, NULL, NULL, 0, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return ret; } %} -%threadallow pkey_write_pem; %inline %{ int pkey_write_pem(EVP_PKEY *pkey, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { int ret; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS ret = PEM_write_bio_PKCS8PrivateKey(f, pkey, cipher, NULL, 0, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return ret; } %} -%threadallow pkey_read_pem; %inline %{ EVP_PKEY *pkey_read_pem(BIO *f, PyObject *pyfunc) { EVP_PKEY *pk; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS pk = PEM_read_bio_PrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return pk; } diff --git a/SWIG/_pkcs7.i b/SWIG/_pkcs7.i index 4256acf..9aba4b5 100644 --- a/SWIG/_pkcs7.i +++ b/SWIG/_pkcs7.i @@ -101,10 +101,9 @@ PKCS7 *pkcs7_sign1(X509 *x509, EVP_PKEY *pkey, STACK_OF(X509) *stack, BIO *bio, } %} -%threadallow pkcs7_verify1; %inline %{ PyObject *pkcs7_verify1(PKCS7 *pkcs7, STACK_OF(X509) *stack, X509_STORE *store, BIO *data, int flags) { - int outlen; + int res, outlen; char *outbuf; BIO *bio; PyObject *ret; @@ -113,7 +112,10 @@ PyObject *pkcs7_verify1(PKCS7 *pkcs7, STACK_OF(X509) *stack, X509_STORE *store, PyErr_SetString(PyExc_MemoryError, "pkcs7_verify1"); return NULL; } - if (!PKCS7_verify(pkcs7, stack, store, data, bio, flags)) { + Py_BEGIN_ALLOW_THREADS + res = PKCS7_verify(pkcs7, stack, store, data, bio, flags); + Py_END_ALLOW_THREADS + if (!res) { PyErr_SetString(_pkcs7_err, ERR_reason_error_string(ERR_get_error())); BIO_free(bio); return NULL; diff --git a/SWIG/_rsa.i b/SWIG/_rsa.i index 3fba66d..af91c5c 100644 --- a/SWIG/_rsa.i +++ b/SWIG/_rsa.i @@ -48,39 +48,42 @@ void rsa_init(PyObject *rsa_err) { } %} -%threadallow rsa_read_key; %inline %{ RSA *rsa_read_key(BIO *f, PyObject *pyfunc) { RSA *rsa; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS rsa = PEM_read_bio_RSAPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return rsa; } %} -%threadallow rsa_write_key; %inline %{ int rsa_write_key(RSA *rsa, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { int ret; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS ret = PEM_write_bio_RSAPrivateKey(f, rsa, cipher, NULL, 0, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return ret; } %} -%threadallow rsa_write_key_no_cipher; %inline %{ int rsa_write_key_no_cipher(RSA *rsa, BIO *f, PyObject *pyfunc) { int ret; Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS ret = PEM_write_bio_RSAPrivateKey(f, rsa, NULL, NULL, 0, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS Py_DECREF(pyfunc); return ret; } -- 1.6.4.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor