Skip to content
forked from neovim/neovim

Commit

Permalink
socket.c: Disable Nagle's algorithm on TCP sockets (neovim#6915)
Browse files Browse the repository at this point in the history
Reducing latency is more interesting than optimizing bandwidth
for Nvim's typical use-cases.
  • Loading branch information
davidgaleano authored and justinmk committed Jun 27, 2017
1 parent 2b377d8 commit 1ef2d76
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/nvim/event/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ int socket_watcher_init(Loop *loop, SocketWatcher *watcher,
watcher->uv.tcp.addrinfo = request.addrinfo;

uv_tcp_init(&loop->uv, &watcher->uv.tcp.handle);
uv_tcp_nodelay(&watcher->uv.tcp.handle, true);
watcher->stream = STRUCT_CAST(uv_stream_t, &watcher->uv.tcp.handle);
} else {
uv_pipe_init(&loop->uv, &watcher->uv.pipe.handle, 0);
Expand Down Expand Up @@ -146,6 +147,7 @@ int socket_watcher_accept(SocketWatcher *watcher, Stream *stream)
if (watcher->stream->type == UV_TCP) {
client = STRUCT_CAST(uv_stream_t, &stream->uv.tcp);
uv_tcp_init(watcher->uv.tcp.handle.loop, (uv_tcp_t *)client);
uv_tcp_nodelay((uv_tcp_t *)client, true);
} else {
client = STRUCT_CAST(uv_stream_t, &stream->uv.pipe);
uv_pipe_init(watcher->uv.pipe.handle.loop, (uv_pipe_t *)client, 0);
Expand Down Expand Up @@ -237,6 +239,7 @@ bool socket_connect(Loop *loop, Stream *stream,

tcp_retry:
uv_tcp_init(&loop->uv, tcp);
uv_tcp_nodelay(tcp, true);
uv_tcp_connect(&req, tcp, addrinfo->ai_addr, connect_cb);
uv_stream = (uv_stream_t *)tcp;

Expand Down

0 comments on commit 1ef2d76

Please sign in to comment.