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

[JGIT PATCH 2/2] Decrease the fetch pack client buffer to the lower minimum

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

This is the lowest buffer size we actually require to keep the client and server sides from deadlocking against each other.

Also added documentation, and renamed the symbol to better match its real purpose; naming the lower threshold we can allow for a buffer.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../jgit/transport/BasePackFetchConnection.java    |   10 +++++++++-
 .../org/spearce/jgit/transport/TransportLocal.java |    2 +-
 2 files changed, 10 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 eaa94bd..1d1b801 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackFetchConnection.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackFetchConnection.java
@@ -89,7 +89,15 @@
 	 */
 	private static final int MAX_HAVES = 256;
 
-	protected static final int MAX_CLIENT_BUFFER = MAX_HAVES * 46 + 1024;
+	/**
+	 * Amount of data the client sends before starting to read.
+	 * <p>
+	 * Any output stream given to the client must be able to buffer this many
+	 * bytes before the client will stop writing and start reading from the
+	 * input stream. If the output stream blocks before this many bytes are in
+	 * the send queue, the system will deadlock.
+	 */
+	protected static final int MIN_CLIENT_BUFFER = 2 * 32 * 46 + 4;
 
 	static final String OPTION_INCLUDE_TAG = "include-tag";
 
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportLocal.java b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportLocal.java
index cffdba1..428f73e 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/TransportLocal.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/TransportLocal.java
@@ -175,7 +175,7 @@ InternalLocalFetchConnection() throws TransportException {
 					// force the buffer to be big enough, otherwise it
 					// will deadlock both threads.
 					{
-						buffer = new byte[MAX_CLIENT_BUFFER];
+						buffer = new byte[MIN_CLIENT_BUFFER];
 					}
 				};
 				out_w = new PipedOutputStream(out_r);
-- 
1.6.3.48.g99c76
Previous: Shawn O. PearceNext: Junio C Hamano
Message 2 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.