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

[JGIT PATCH 1/2] Fix deadlock in native git protocol client for upload-pack

From
Shawn O. Pearce <spearce@spearce.org>
Date
May 10, 2009, 22:48 UTC
Message-ID
<1241995685-13260-1-git-send-email-spearce@spearce.org>

The upload-pack protocol states that for every flush packet (aka "0000") sent by the client, we get exactly one NAK or ACK line back. However, if multi_ack is enabled, we may get multiple "ACK %s continue" lines before the ACK/NAK is sent by the upload-pack server.

Unfortunately, JGit was counting an "ACK %s continue" as a response to a flush packet, causing the client side to stop reading from the server too early. This left a lot of "ACK %s continue" lines in the server output buffer, eventually causing the server to stop and wait for the output buffer to drain. However, the client would also get stuck after sending too many "have %s" lines, eventually deadlocking the entire client-server pair.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../jgit/transport/BasePackFetchConnection.java    |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackFetchConnection.java b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackFetchConnection.java
index f07cc4e..eaa94bd 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackFetchConnection.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackFetchConnection.java
@@ -359,15 +359,15 @@ private void negotiate(final ProgressMonitor monitor) throws IOException,
 				continue;
 			}
 
-			while (resultsPending > 0) {
+			for (;;) {
 				final PacketLineIn.AckNackResult anr;
 
 				anr = pckIn.readACK(ackId);
-				resultsPending--;
 				if (anr == PacketLineIn.AckNackResult.NAK) {
 					// More have lines are necessary to compute the
 					// pack on the remote side. Keep doing that.
 					//
+					resultsPending--;
 					break;
 				}
 
-- 
1.6.3.48.g99c76
Next: Shawn O. Pearce
Message 1 of 7 in “Fix deadlock in native git protocol client for upload-pack”
  1. 1/2 Fix deadlock in native git protocol client for upload-packShawn O. Pearce, May 10, 2009
  2. 2/2 Decrease the fetch pack client buffer to the lower minimumShawn O. Pearce, May 10, 2009
  3. Junio C HamanoMay 11, 2009
  4. Shawn O. PearceMay 11, 2009
  5. Junio C HamanoMay 11, 2009
  6. Shawn O. PearceMay 11, 2009
  7. (unknown)Carl Mercier, May 11, 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.