This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rv
Recipients bob.bob, giampaolo.rodola, loewis, pitrou, rv, vstinner
Date 2014-04-08.15:10:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1396969844.66.0.856597876799.issue20924@psf.upfronthosting.co.za>
In-reply-to
Content
Antoine, Martin, thank you for your replies. You was right: NT socket was not in blocking mode (in 1st case). I didn't knew how to determine socket mode in NT, so I explicitly set socket mode to blocking in _ssl.c before calling SSL_do_handshake() for test:

_ssl.c::PySSL_SSLdo_handshake():

	// ------------ Explicitly set blocking mode
	unsigned long iMode = 0UL; // If iMode = 0, blocking is enabled; 
	int iResult = ioctlsocket( self->Socket->sock_fd, FIONBIO, &iMode );
	if (iResult != NO_ERROR)
		printf("\nioctlsocket failed with error: %ld\n", iResult);
	// ------------
	PySSL_BEGIN_ALLOW_THREADS
	ret = SSL_do_handshake(self->ssl);
	...

Test result: SSL_do_handshake() did not return (and no CPU load).

But in general, I think that check_socket_and_wait_for_timeout() logic is erroneous:
	if (s->sock_timeout < 0.0)
		return SOCKET_IS_BLOCKING;

By default (see case #1 in my message above), timeout in Python wrapping object is -1 (self->Socket->sock_timeout==-1). But underlying NT socket is really non-blocking. This leads to 100% CPU load: PySSL_SSLdo_handshake() loop is calling check_socket_and_wait_for_timeout() which immediately returns.

NB. I use Python 2.7.6 and openssl-0.9.8y for my build and never tried Python 3.
History
Date User Action Args
2014-04-08 15:10:44rvsetrecipients: + rv, loewis, pitrou, vstinner, giampaolo.rodola, bob.bob
2014-04-08 15:10:44rvsetmessageid: <1396969844.66.0.856597876799.issue20924@psf.upfronthosting.co.za>
2014-04-08 15:10:44rvlinkissue20924 messages
2014-04-08 15:10:44rvcreate