diff mbox series

[v2,3/5] remote-curl: simplify rpc_out() - remove superfluous ifs

Message ID CAGE_+C58LWwF5YAm+S3Ynev+mTnm_ZSVuir9sZsHmeB+56T1kA@mail.gmail.com (mailing list archive)
State New, archived
Headers show
Series remote-curl: avoid hang if curl asks for more data after eof | expand

Commit Message

Jiří Hruška Nov. 15, 2023, 3:34 a.m. UTC
Remove the second set of nested `if` statements and an early `return`
in `rpc_out()`, because they accomplish nothing. The rest of the
function would behave the same without any branching.

Signed-off-by: Jiri Hruska <jirka@fud.cz>
---
 remote-curl.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/remote-curl.c b/remote-curl.c
index 428dd70aa1..690df2a43e 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -706,25 +706,13 @@  static size_t rpc_out(void *ptr, size_t eltsize,
 		 * we need to refrain from reading.
 		 */
 	}
-	if (rpc->flush_read_but_not_sent) {
-		if (!avail) {
-			/*
-			 * The line length either does not need to be sent at
-			 * all or has already been completely sent. Now we can
-			 * return 0, indicating EOF, meaning that the flush has
-			 * been fully sent. It is important to keep returning 0
-			 * as long as needed in that case, as libcurl invokes
-			 * the callback multiple times at EOF sometimes.
-			 */
-			return 0;
-		}
-		/*
-		 * If avail is non-zero, the line length for the flush still
-		 * hasn't been fully sent. Proceed with sending the line
-		 * length.
-		 */
-	}

+	/*
+	 * Copy data to the provided buffer. If there is nothing more to send,
+	 * nothing gets written and the return value is 0 (EOF).
+	 * It is important to keep returning 0 as long as needed in that case,
+	 * as libcurl invokes the callback multiple times at EOF sometimes.
+	 */
 	if (max < avail)
 		avail = max;
 	memcpy(ptr, rpc->buf + rpc->pos, avail);