summaryrefslogtreecommitdiffstats
path: root/Utilities/cmlibuv/src/unix/tcp.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-04-06 15:58:14 (GMT)
committerBrad King <brad.king@kitware.com>2020-04-06 15:58:14 (GMT)
commit722d6b41053c6f143e10468d2ea25146a3dcf7a5 (patch)
tree1cd58dcc2f2a255d6cc388f45d4883b0757d262a /Utilities/cmlibuv/src/unix/tcp.c
parent21c5a311c60da34d4e66a1d1a778106110f9b5d2 (diff)
parent394b07af40e1bdbdca0033e53ca803585454da18 (diff)
downloadCMake-722d6b41053c6f143e10468d2ea25146a3dcf7a5.zip
CMake-722d6b41053c6f143e10468d2ea25146a3dcf7a5.tar.gz
CMake-722d6b41053c6f143e10468d2ea25146a3dcf7a5.tar.bz2
Merge branch 'upstream-libuv' into update-libuv
* upstream-libuv: libuv 2020-04-06 (d21f5aea)
Diffstat (limited to 'Utilities/cmlibuv/src/unix/tcp.c')
-rw-r--r--Utilities/cmlibuv/src/unix/tcp.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/Utilities/cmlibuv/src/unix/tcp.c b/Utilities/cmlibuv/src/unix/tcp.c
index 8cedcd6..d47e943 100644
--- a/Utilities/cmlibuv/src/unix/tcp.c
+++ b/Utilities/cmlibuv/src/unix/tcp.c
@@ -308,6 +308,23 @@ int uv_tcp_getpeername(const uv_tcp_t* handle,
}
+int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb) {
+ int fd;
+ struct linger l = { 1, 0 };
+
+ /* Disallow setting SO_LINGER to zero due to some platform inconsistencies */
+ if (handle->flags & UV_HANDLE_SHUTTING)
+ return UV_EINVAL;
+
+ fd = uv__stream_fd(handle);
+ if (0 != setsockopt(fd, SOL_SOCKET, SO_LINGER, &l, sizeof(l)))
+ return UV__ERR(errno);
+
+ uv_close((uv_handle_t*) handle, close_cb);
+ return 0;
+}
+
+
int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
static int single_accept = -1;
unsigned long flags;
@@ -362,8 +379,16 @@ int uv__tcp_keepalive(int fd, int on, unsigned int delay) {
return UV__ERR(errno);
#ifdef TCP_KEEPIDLE
- if (on && setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &delay, sizeof(delay)))
- return UV__ERR(errno);
+ if (on) {
+ int intvl = 1; /* 1 second; same as default on Win32 */
+ int cnt = 10; /* 10 retries; same as hardcoded on Win32 */
+ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &delay, sizeof(delay)))
+ return UV__ERR(errno);
+ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl)))
+ return UV__ERR(errno);
+ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt)))
+ return UV__ERR(errno);
+ }
#endif
/* Solaris/SmartOS, if you don't support keep-alive,