Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 20d6080

Browse files
author
Stefan Krah
committed
Issue #16982: Fix --without-threads build failure.
1 parent 6a56b8a commit 20d6080

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

Modules/_ssl.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,15 +2392,17 @@ _servername_callback(SSL *s, int *al, void *args)
23922392
PyObject *result;
23932393
/* The high-level ssl.SSLSocket object */
23942394
PyObject *ssl_socket;
2395-
PyGILState_STATE gstate;
23962395
const char *servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
2397-
2398-
gstate = PyGILState_Ensure();
2396+
#ifdef WITH_THREAD
2397+
PyGILState_STATE gstate = PyGILState_Ensure();
2398+
#endif
23992399

24002400
if (ssl_ctx->set_hostname == NULL) {
24012401
/* remove race condition in this the call back while if removing the
24022402
* callback is in progress */
2403+
#ifdef WITH_THREAD
24032404
PyGILState_Release(gstate);
2405+
#endif
24042406
return SSL_TLSEXT_ERR_OK;
24052407
}
24062408

@@ -2449,14 +2451,18 @@ _servername_callback(SSL *s, int *al, void *args)
24492451
Py_DECREF(result);
24502452
}
24512453

2454+
#ifdef WITH_THREAD
24522455
PyGILState_Release(gstate);
2456+
#endif
24532457
return ret;
24542458

24552459
error:
24562460
Py_DECREF(ssl_socket);
24572461
*al = SSL_AD_INTERNAL_ERROR;
24582462
ret = SSL_TLSEXT_ERR_ALERT_FATAL;
2463+
#ifdef WITH_THREAD
24592464
PyGILState_Release(gstate);
2465+
#endif
24602466
return ret;
24612467
}
24622468

0 commit comments

Comments
 (0)