git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] jgit: upload-pack: Force an fd flush after receiving flush pkt from client

From
Shawn O. Pearce <spearce@spearce.org>
Date
Mar 16, 2009, 20:05 UTC
Message-ID
<20090316200515.GQ22920@spearce.org>
In-Reply-To
<1237224864-15649-1-git-send-email-dima@android.com>
Dima Zavin <dima@android.com> wrote:
Show 13 quoted lines
> diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java
> index 71acda1..80c154b 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java
> @@ -351,7 +351,7 @@ private void negotiate() throws IOException {
>  			if (line.length() == 0) {
>  				if (commonBase.isEmpty() || multiAck)
>  					pckOut.writeString("NAK\n");
> -
> +				pckOut.flush();
>  			} else if (line.startsWith("have ") && line.length() == 45) {
>  				final ObjectId id = ObjectId.fromString(line.substring(5));
>  				if (matchHave(id)) {
Applied, but with this more verbose commit message:

--8<-- upload-pack: Force an fd flush after receiving flush pkt from client

The client is blocked waiting for an ACK or NAK line from the server. If we don't call flush() here there is a very good chance the ACK/NAK is stuck in our stream buffer within the JRE, and doesn't make it into the kernel's TCP buffer. This causes the server to wait for more have lines, and the client to wait for the ACK/NAK, and the entire thing just deadlocks.

We flush anytime we see a pkt-line flush command, as there may be buffered ACK lines from prior evaulations that need to be sent to the waiting client.

Signed-off-by: Dima Zavin <dima@android.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
-- 
Shawn.
Previous: Dima Zavin
Message 2 of 2 in “jgit: upload-pack: Force an fd flush after receiving flush pkt from client”
  1. jgit: upload-pack: Force an fd flush after receiving flush pkt from clientDima Zavin, Mar 16, 2009
  2. Shawn O. PearceMar 16, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.