/* Lock to allow python interpreter to continue, but only allow one
thread to be in gethostbyname or getaddrinfo */
#if defined(USE_GETHOSTBYNAME_LOCK)
-static PyThread_type_lock netdb_lock;
+static PyMutex netdb_lock = {0};
#endif
#endif
#else /* not HAVE_GETHOSTBYNAME_R */
#ifdef USE_GETHOSTBYNAME_LOCK
- PyThread_acquire_lock(netdb_lock, 1);
+ PyMutex_Lock(&netdb_lock);
#endif
_Py_COMP_DIAG_PUSH
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
ret = gethost_common(state, h, SAS2SA(&addr), sizeof(addr),
sa->sa_family);
#ifdef USE_GETHOSTBYNAME_LOCK
- PyThread_release_lock(netdb_lock);
+ PyMutex_Unlock(&netdb_lock);
#endif
finally:
PyMem_Free(name);
#endif
#else /* not HAVE_GETHOSTBYNAME_R */
#ifdef USE_GETHOSTBYNAME_LOCK
- PyThread_acquire_lock(netdb_lock, 1);
+ PyMutex_Lock(&netdb_lock);
#endif
_Py_COMP_DIAG_PUSH
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
Py_END_ALLOW_THREADS
ret = gethost_common(state, h, SAS2SA(&addr), sizeof(addr), af);
#ifdef USE_GETHOSTBYNAME_LOCK
- PyThread_release_lock(netdb_lock);
+ PyMutex_Unlock(&netdb_lock);
#endif
finally:
PyMem_Free(ip_num);
#endif
#endif /* _MSTCPIP_ */
- /* Initialize gethostbyname lock */
-#if defined(USE_GETHOSTBYNAME_LOCK)
- netdb_lock = PyThread_allocate_lock();
- if (netdb_lock == NULL) {
- PyErr_NoMemory();
- goto error;
- }
-#endif
-
#ifdef MS_WINDOWS
/* remove some flags on older version Windows during run-time */
if (remove_unusable_flags(m) < 0) {