This makes it possible to both enable and disable Nagle's algorithm
for a TCP socket descriptor, before the change it was possible only to
disable it.
(void)uv_fileno((uv_handle_t *)&tcpsock->uv_handle.tcp, &tcp_fd);
RUNTIME_CHECK(tcp_fd != (uv_os_fd_t)-1);
- (void)isc__nm_socket_tcp_nodelay((uv_os_sock_t)tcp_fd);
+ (void)isc__nm_socket_tcp_nodelay((uv_os_sock_t)tcp_fd, true);
}
static isc_result_t
*/
isc_result_t
-isc__nm_socket_tcp_nodelay(uv_os_sock_t fd);
+isc__nm_socket_tcp_nodelay(const uv_os_sock_t fd, bool value);
/*%<
- * Disables Nagle's algorithm on a TCP socket (sets TCP_NODELAY).
+ * Disables/Enables Nagle's algorithm on a TCP socket (sets TCP_NODELAY if
+ * 'value' equals 'true' or vice versa).
*/
isc_result_t
}
isc_result_t
-isc__nm_socket_tcp_nodelay(uv_os_sock_t fd) {
+isc__nm_socket_tcp_nodelay(uv_os_sock_t fd, bool value) {
#ifdef TCP_NODELAY
- if (setsockopt_on(fd, IPPROTO_TCP, TCP_NODELAY) == -1) {
+ int ret;
+
+ if (value) {
+ ret = setsockopt_on(fd, IPPROTO_TCP, TCP_NODELAY);
+ } else {
+ ret = setsockopt_off(fd, IPPROTO_TCP, TCP_NODELAY);
+ }
+
+ if (ret == -1) {
return (ISC_R_FAILURE);
} else {
return (ISC_R_SUCCESS);