Skip to content

Commit

Permalink
Set TCP_NODELAY on the socket
Browse files Browse the repository at this point in the history
Nagle's algorithm probably serves no purpose with whois queries
often being tiny.
  • Loading branch information
job committed May 10, 2024
1 parent 4bac9e7 commit 424770b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.14
- Set TCP_NODELAY on the whois socket

1.13 (2024-05-01)
- Fixed a bug for Mac users by removing sx_maxsockbuf()

Expand Down
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ maintainer-clean-local:
check:
./bgpq4 -v
@echo
-@if [ -s /etc/resolv.conf ]; then \
./bgpq4 -6 AS15562:AS-SNIJDERS | grep 2001:67c:208c::; \
-if [ -s /etc/resolv.conf ]; then \
./bgpq4 -ddd -6 AS15562:AS-SNIJDERS ; \
else \
echo "No or empty /etc/resolv.conf, skipping online test"; \
fi
8 changes: 7 additions & 1 deletion expander.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <netinet/tcp.h>

#include <assert.h>
#include <ctype.h>
Expand Down Expand Up @@ -1034,7 +1035,7 @@ bgpq_expand(struct bgpq_expander *b)
struct addrinfo hints, *res = NULL, *rp;
struct linger sl;
struct asn_entry *asne;
int fd = -1, err, ret, aquery = 0;
int fd = -1, err, ret, aquery = 0, nodelay = 1;
int slen;

sl.l_onoff = 1;
Expand Down Expand Up @@ -1075,6 +1076,11 @@ bgpq_expand(struct bgpq_expander *b)
continue;
}

if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &nodelay,
sizeof(nodelay)) == -1)
SX_DEBUG(debug_expander, "Unable to set TCP_NODELAY on"
" socket: %s\n", strerror(errno));

break;
}

Expand Down

0 comments on commit 424770b

Please sign in to comment.