Use uv_sleep in the netmgr code

libuv added uv_sleep(unsigned int msec) to the API since 1.34.0.  Use that in
the netmgr code and define usleep based shim for libuv << 1.34.0.
This commit is contained in:
Ondřej Surý 2021-05-03 12:10:03 +02:00
parent c37ff5d188
commit 37c0d196e3
3 changed files with 7 additions and 11 deletions

View file

@ -600,7 +600,7 @@ LIBS="$LIBS $LIBUV_LIBS"
# Those functions are only provided in newer versions of libuv, we'll be emulating them
# for now
AC_CHECK_FUNCS([uv_handle_get_data uv_handle_set_data uv_import uv_udp_connect uv_translate_sys_error])
AC_CHECK_FUNCS([uv_handle_get_data uv_handle_set_data uv_import uv_udp_connect uv_translate_sys_error uv_sleep])
AX_RESTORE_FLAGS([libuv])
# libnghttp2

View file

@ -512,11 +512,7 @@ isc_nm_destroy(isc_nm_t **mgr0) {
* Wait for the manager to be dereferenced elsewhere.
*/
while (isc_refcount_current(&mgr->references) > 1 && counter++ < 1000) {
#ifdef WIN32
_sleep(10);
#else /* ifdef WIN32 */
usleep(10000);
#endif /* ifdef WIN32 */
uv_sleep(10);
}
#ifdef NETMGR_TRACE
@ -531,11 +527,7 @@ isc_nm_destroy(isc_nm_t **mgr0) {
* Now just patiently wait
*/
while (isc_refcount_current(&mgr->references) > 1) {
#ifdef WIN32
_sleep(10);
#else /* ifdef WIN32 */
usleep(10000);
#endif /* ifdef WIN32 */
uv_sleep(10);
}
/*

View file

@ -33,6 +33,10 @@ uv_handle_set_data(uv_handle_t *handle, void *data) {
}
#endif /* ifndef HAVE_UV_HANDLE_SET_DATA */
#ifndef HAVE_UV_SLEEP
#define uv_sleep(msec) usleep(msec * 1000)
#endif
#ifdef HAVE_UV_UDP_CONNECT
#define isc_uv_udp_connect uv_udp_connect
#else