Add uv_tcp_close_reset compat
The uv_tcp_close_reset() function was added in libuv 1.32.0 and since we support older libuv releases, we have to add a shim uv_tcp_close_reset() implementation loosely based on libuv.
This commit is contained in:
@@ -42,6 +42,24 @@ isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
|
||||
}
|
||||
#endif /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
|
||||
|
||||
#if UV_VERSION_HEX < UV_VERSION(1, 32, 0)
|
||||
int
|
||||
uv_tcp_close_reset(uv_tcp_t *handle, uv_close_cb close_cb) {
|
||||
if (setsockopt(handle->io_watcher.fd, SOL_SOCKET, SO_LINGER,
|
||||
&(struct linger){ 1, 0 }, sizeof(struct linger)) == -1)
|
||||
{
|
||||
#if UV_VERSION_HEX >= UV_VERSION(1, 10, 0)
|
||||
return (uv_translate_sys_error(errno));
|
||||
#else
|
||||
return (-errno);
|
||||
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 10, 0) */
|
||||
}
|
||||
|
||||
uv_close((uv_handle_t *)handle, close_cb);
|
||||
return (0);
|
||||
}
|
||||
#endif /* UV_VERSION_HEX < UV_VERSION(1, 32, 0) */
|
||||
|
||||
int
|
||||
isc_uv_udp_freebind(uv_udp_t *handle, const struct sockaddr *addr,
|
||||
unsigned int flags) {
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
|
||||
#define UV_VERSION(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
|
||||
|
||||
#if !defined(UV__ERR)
|
||||
#define UV__ERR(x) (-(x))
|
||||
#endif
|
||||
|
||||
#if UV_VERSION_HEX < UV_VERSION(1, 19, 0)
|
||||
static inline void *
|
||||
uv_handle_get_data(const uv_handle_t *handle) {
|
||||
@@ -45,6 +49,11 @@ uv_req_set_data(uv_req_t *req, void *data) {
|
||||
}
|
||||
#endif /* UV_VERSION_HEX < UV_VERSION(1, 19, 0) */
|
||||
|
||||
#if UV_VERSION_HEX < UV_VERSION(1, 32, 0)
|
||||
int
|
||||
uv_tcp_close_reset(uv_tcp_t *handle, uv_close_cb close_cb);
|
||||
#endif
|
||||
|
||||
#if UV_VERSION_HEX < UV_VERSION(1, 34, 0)
|
||||
#define uv_sleep(msec) usleep(msec * 1000)
|
||||
#endif /* UV_VERSION_HEX < UV_VERSION(1, 34, 0) */
|
||||
|
||||
Reference in New Issue
Block a user