Skip to content

Commit 7ea2613

Browse files
committed
Some other fixups.
1 parent 90d93c3 commit 7ea2613

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

Lib/test/test_ssl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4630,6 +4630,7 @@ def test_thread_recv_while_main_thread_sends(self):
46304630
# that the recv() call held.
46314631
data = b"1" * 50
46324632
event = threading.Event()
4633+
import time
46334634
def background(sock):
46344635
event.set()
46354636
received = sock.recv(50)
@@ -4646,8 +4647,8 @@ def background(sock):
46464647
thread = threading.Thread(target=background,
46474648
args=(sock,), daemon=True)
46484649
thread.start()
4649-
# Use two events to prevent some race conditions here.
46504650
event.wait()
4651+
time.sleep(0)
46514652
sock.sendall(b"1" * 50)
46524653
thread.join()
46534654
if cm.exc_value is not None:

Modules/_ssl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,11 +990,12 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
990990
BIO_set_nbio(SSL_get_wbio(self->ssl), 1);
991991
}
992992

993-
// No other threads can have access to this, so no need to lock it.
993+
Py_BEGIN_ALLOW_THREADS;
994994
if (socket_type == PY_SSL_CLIENT)
995995
SSL_set_connect_state(self->ssl);
996996
else
997997
SSL_set_accept_state(self->ssl);
998+
Py_END_ALLOW_THREADS;
998999

9991000
self->socket_type = socket_type;
10001001
if (sock != NULL) {

0 commit comments

Comments
 (0)