git: 08c33cd94da1 - main - hpts: avoid duplicate call to tcp_output()

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Tue, 26 Dec 2023 21:12:23 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=08c33cd94da18b4cae73a4837e13f677345a6c1e

commit 08c33cd94da18b4cae73a4837e13f677345a6c1e
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2023-12-26 21:09:09 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2023-12-26 21:09:09 +0000

    hpts: avoid duplicate call to tcp_output()
    
    Obtained from:  rrs
---
 sys/netinet/tcp_hpts.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/sys/netinet/tcp_hpts.c b/sys/netinet/tcp_hpts.c
index a6fa79a26949..73e9997c060f 100644
--- a/sys/netinet/tcp_hpts.c
+++ b/sys/netinet/tcp_hpts.c
@@ -1364,18 +1364,23 @@ again:
 			 * We also only call tfb_do_queued_segments() <or>
 			 * tcp_output().  It is expected that if segments are
 			 * queued and come in that the final input mbuf will
-			 * cause a call to output if it is needed.
+			 * cause a call to output if it is needed so we do
+			 * not need a second call to tcp_output(). So we do
+			 * one or the other but not both.
 			 */
 			tp->t_flags2 |= TF2_HPTS_CALLS;
 			if ((tp->t_flags2 & TF2_SUPPORTS_MBUFQ) &&
 			    !STAILQ_EMPTY(&tp->t_inqueue)) {
 				error = (*tp->t_fb->tfb_do_queued_segments)(tp, 0);
-				if (error) {
-					/* The input killed the connection */
+				/*
+				 * A non-zero return for input queue processing
+				 * is the lock is released and most likely the
+				 * inp is gone.
+				 */
+				if (error)
 					goto skip_pacing;
-				}
-			}
-			error = tcp_output(tp);
+			} else
+				error = tcp_output(tp);
 			if (error < 0)
 				goto skip_pacing;
 			INP_WUNLOCK(inp);