[Python-checkins] python/dist/src/Modules _ssl.c,1.6,1.7

loewis@users.sourceforge.net loewis@users.sourceforge.net
Sun, 28 Jul 2002 02:57:47 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv17327

Modified Files:
	_ssl.c 
Log Message:
Patch #575827: allow threads inside SSL creation.


Index: _ssl.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_ssl.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** _ssl.c	17 Jul 2002 16:30:35 -0000	1.6
--- _ssl.c	28 Jul 2002 09:57:45 -0000	1.7
***************
*** 187,191 ****
--- 187,193 ----
  	}
  
+ 	Py_BEGIN_ALLOW_THREADS
  	self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */
+ 	Py_END_ALLOW_THREADS
  	if (self->ctx == NULL) {
  		errstr = "SSL_CTX_new error";
***************
*** 194,205 ****
  
  	if (key_file) {
! 		if (SSL_CTX_use_PrivateKey_file(self->ctx, key_file,
! 						SSL_FILETYPE_PEM) < 1) {
  			errstr = "SSL_CTX_use_PrivateKey_file error";
  			goto fail;
  		}
  
! 		if (SSL_CTX_use_certificate_chain_file(self->ctx,
! 						       cert_file) < 1) {
  			errstr = "SSL_CTX_use_certificate_chain_file error";
  			goto fail;
--- 196,213 ----
  
  	if (key_file) {
! 		Py_BEGIN_ALLOW_THREADS
! 		ret = SSL_CTX_use_PrivateKey_file(self->ctx, key_file,
! 						SSL_FILETYPE_PEM);
! 		Py_END_ALLOW_THREADS
! 		if (ret < 1) {
  			errstr = "SSL_CTX_use_PrivateKey_file error";
  			goto fail;
  		}
  
! 		Py_BEGIN_ALLOW_THREADS
! 		ret = SSL_CTX_use_certificate_chain_file(self->ctx,
! 						       cert_file);
! 		Py_END_ALLOW_THREADS
! 		if (ret < 1) {
  			errstr = "SSL_CTX_use_certificate_chain_file error";
  			goto fail;
***************
*** 207,219 ****
--- 215,232 ----
  	}
  
+ 	Py_BEGIN_ALLOW_THREADS
  	SSL_CTX_set_verify(self->ctx,
  			   SSL_VERIFY_NONE, NULL); /* set verify lvl */
  	self->ssl = SSL_new(self->ctx); /* New ssl struct */
+ 	Py_END_ALLOW_THREADS
  	SSL_set_fd(self->ssl, Sock->sock_fd);	/* Set the socket for SSL */
+ 	Py_BEGIN_ALLOW_THREADS
  	SSL_set_connect_state(self->ssl);
  
+ 
  	/* Actually negotiate SSL connection */
  	/* XXX If SSL_connect() returns 0, it's also a failure. */
  	ret = SSL_connect(self->ssl);
+ 	Py_END_ALLOW_THREADS
  	if (ret <= 0) {
  		PySSL_SetError(self, ret);
***************
*** 222,225 ****
--- 235,239 ----
  	self->ssl->debug = 1;
  
+ 	Py_BEGIN_ALLOW_THREADS
  	if ((self->server_cert = SSL_get_peer_certificate(self->ssl))) {
  		X509_NAME_oneline(X509_get_subject_name(self->server_cert),
***************
*** 228,231 ****
--- 242,246 ----
  				  self->issuer, X509_NAME_MAXLEN);
  	}
+ 	Py_END_ALLOW_THREADS
  	self->Socket = Sock;
  	Py_INCREF(self->Socket);