Skip to content

Commit

Permalink
Use TCP_NODELAY for TCP connections (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefantalpalaru authored May 10, 2024
1 parent f85cd7e commit 009ed45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

### All Platforms
- Set up a Transifex project to manage translations ([#20](https://github.com/stefantalpalaru/transmission-og/pull/20))
- use clang-format to automate code formatting ([#22](https://github.com/stefantalpalaru/transmission-og/pull/22))
- Use clang-format to automate code formatting ([#22](https://github.com/stefantalpalaru/transmission-og/pull/22))
- Windows: remove MSI installer ([#24](https://github.com/stefantalpalaru/transmission-og/pull/24))
- Use TCP\_NODELAY for TCP connections ([#26](https://github.com/stefantalpalaru/transmission-og/pull/26))

### Mac Client
- Update Sparkle to 2.6.2, to allow building on ARM64 macOS ([#25](https://github.com/stefantalpalaru/transmission-og/pull/25))
Expand Down
8 changes: 6 additions & 2 deletions libtransmission/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,19 @@ static tr_socket_t tr_netBindTCPImpl(tr_address const *addr, tr_port port, bool
tr_logAddDebug("Bound socket %" PRIdMAX " to port %d on %s", (intmax_t)fd, port, tr_address_to_string(addr));
}

#ifdef TCP_FASTOPEN

// for macOS: https://github.com/unbit/uwsgi/pull/966
#ifndef SOL_TCP
#define SOL_TCP IPPROTO_TCP
#endif

#ifdef TCP_FASTOPEN
optval = 5;
setsockopt(fd, SOL_TCP, TCP_FASTOPEN, (void const *)&optval, sizeof(optval));
#endif

#ifdef TCP_NODELAY
optval = 1;
setsockopt(fd, SOL_TCP, TCP_NODELAY, (void const *)&optval, sizeof(optval));
#endif

if (listen(fd, 128) == -1) {
Expand Down

0 comments on commit 009ed45

Please sign in to comment.