|
|
689258 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
689258 |
From: Sergio Durigan Junior <sergiodj@redhat.com>
|
|
|
689258 |
Date: Fri, 3 Aug 2018 18:04:38 -0400
|
|
|
689258 |
Subject: gdb-rhbz881849-ipv6-3of3.patch
|
|
|
689258 |
|
|
|
689258 |
Fix thinko when deciding whether to disable TCP's Nagle algorithm
|
|
|
689258 |
|
|
|
689258 |
This patch fixes a thinko that happened when I was implementing the
|
|
|
689258 |
IPv6 support on GDB/gdbserver. On certain situations, it is necessary
|
|
|
689258 |
to disable TCP's Nagle algorithm (NODELAY). For obvious reasons, this
|
|
|
689258 |
only applies when we are dealing with a TCP connection.
|
|
|
689258 |
|
|
|
689258 |
While implementing the IPv6 patch, I noticed that the net_open
|
|
|
689258 |
function (on gdb/ser-tcp.c) kept a flag indicating whether the
|
|
|
689258 |
connection type was UDP or TCP. I eliminated that flag, and started
|
|
|
689258 |
using the 'struct addrinfo *' related to the successful connection
|
|
|
689258 |
directly. However, I made a mistake:
|
|
|
689258 |
|
|
|
689258 |
if (success_ainfo->ai_socktype == IPPROTO_TCP)
|
|
|
689258 |
^^^^^^^^^^^
|
|
|
689258 |
{
|
|
|
689258 |
/* Disable Nagle algorithm. Needed in some cases. */
|
|
|
689258 |
int tmp = 1;
|
|
|
689258 |
|
|
|
689258 |
setsockopt (scb->fd, IPPROTO_TCP, TCP_NODELAY,
|
|
|
689258 |
(char *) &tmp, sizeof (tmp));
|
|
|
689258 |
}
|
|
|
689258 |
|
|
|
689258 |
The 'ai_socktype' field specifies the socket type (SOCK_STREAM or
|
|
|
689258 |
SOCK_DGRAM), and not the protocol. This test was always failing, and
|
|
|
689258 |
the Nagle algorithm was never being disabled.
|
|
|
689258 |
|
|
|
689258 |
The obvious fix is to use the 'ai_protocol' field. This is what this
|
|
|
689258 |
patch does.
|
|
|
689258 |
|
|
|
689258 |
Huge "thank you" to Joel Brobecker who reported the regression (he was
|
|
|
689258 |
experiencing an unusual delay while debugging a bare-metal program
|
|
|
689258 |
running under QEMU) and helped me set up a proper reproducer for the
|
|
|
689258 |
bug.
|
|
|
689258 |
|
|
|
689258 |
gdb/ChangeLog:
|
|
|
689258 |
2018-08-03 Sergio Durigan Junior <sergiodj@redhat.com>
|
|
|
689258 |
|
|
|
689258 |
* ser-tcp.c (net_open): Fix thinko when deciding whether to
|
|
|
689258 |
disable TCP's Nagle algorithm (use "ai_protocol" instead of
|
|
|
689258 |
"ai_socktype").
|
|
|
689258 |
|
|
|
689258 |
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
|
|
|
689258 |
--- a/gdb/ChangeLog
|
|
|
689258 |
+++ b/gdb/ChangeLog
|
|
|
689258 |
@@ -1,3 +1,9 @@
|
|
|
689258 |
+2018-08-03 Sergio Durigan Junior <sergiodj@redhat.com>
|
|
|
689258 |
+
|
|
|
689258 |
+ * ser-tcp.c (net_open): Fix thinko when deciding whether to
|
|
|
689258 |
+ disable TCP's Nagle algorithm (use "ai_protocol" instead of
|
|
|
689258 |
+ "ai_socktype").
|
|
|
689258 |
+
|
|
|
689258 |
2018-09-05 Joel Brobecker <brobecker@adacore.com>
|
|
|
689258 |
|
|
|
689258 |
* version.in: Set GDB version number to 8.2.
|
|
|
689258 |
diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c
|
|
|
689258 |
--- a/gdb/ser-tcp.c
|
|
|
689258 |
+++ b/gdb/ser-tcp.c
|
|
|
689258 |
@@ -367,7 +367,7 @@ net_open (struct serial *scb, const char *name)
|
|
|
689258 |
|
|
|
689258 |
ioctl (scb->fd, FIONBIO, &ioarg);
|
|
|
689258 |
|
|
|
689258 |
- if (success_ainfo->ai_socktype == IPPROTO_TCP)
|
|
|
689258 |
+ if (success_ainfo->ai_protocol == IPPROTO_TCP)
|
|
|
689258 |
{
|
|
|
689258 |
/* Disable Nagle algorithm. Needed in some cases. */
|
|
|
689258 |
int tmp = 1;
|