1
0
mirror of https://github.com/bgp/bgpq4.git synced 2024-05-11 05:55:05 +00:00

Set TCP_NODELAY on the socket

Nagle's algorithm probably serves no purpose with whois queries
often being tiny.
This commit is contained in:
Job Snijders
2024-05-10 09:41:28 +00:00
parent 4bac9e7e53
commit 424770be0b
3 changed files with 12 additions and 3 deletions

View File

@ -1,3 +1,6 @@
1.14
- Set TCP_NODELAY on the whois socket
1.13 (2024-05-01) 1.13 (2024-05-01)
- Fixed a bug for Mac users by removing sx_maxsockbuf() - Fixed a bug for Mac users by removing sx_maxsockbuf()

View File

@ -36,8 +36,8 @@ maintainer-clean-local:
check: check:
./bgpq4 -v ./bgpq4 -v
@echo @echo
-@if [ -s /etc/resolv.conf ]; then \ -if [ -s /etc/resolv.conf ]; then \
./bgpq4 -6 AS15562:AS-SNIJDERS | grep 2001:67c:208c::; \ ./bgpq4 -ddd -6 AS15562:AS-SNIJDERS ; \
else \ else \
echo "No or empty /etc/resolv.conf, skipping online test"; \ echo "No or empty /etc/resolv.conf, skipping online test"; \
fi fi

View File

@ -29,6 +29,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/select.h> #include <sys/select.h>
#include <netinet/tcp.h>
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
@ -1034,7 +1035,7 @@ bgpq_expand(struct bgpq_expander *b)
struct addrinfo hints, *res = NULL, *rp; struct addrinfo hints, *res = NULL, *rp;
struct linger sl; struct linger sl;
struct asn_entry *asne; struct asn_entry *asne;
int fd = -1, err, ret, aquery = 0; int fd = -1, err, ret, aquery = 0, nodelay = 1;
int slen; int slen;
sl.l_onoff = 1; sl.l_onoff = 1;
@ -1075,6 +1076,11 @@ bgpq_expand(struct bgpq_expander *b)
continue; 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; break;
} }