From a128cb3434d12fb314657e6f69f8ee0315b14b8b Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 10 May 2009 15:48:05 -0700 Subject: [PATCH] Decrease the fetch pack client buffer to the lower minimum 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 Signed-off-by: Robin Rosenberg --- .../org/spearce/jgit/transport/BasePackFetchConnection.java | 10 +++++++++- .../src/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 eaa94bd4..7163e022 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 @@ abstract class BasePackFetchConnection extends BasePackConnection implements */ 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. + *

+ * 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 + 8; 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 cffdba1f..428f73ea 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 @@ class TransportLocal extends Transport implements PackTransport { // 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); -- 2.11.4.GIT