]> source.dussan.org Git - jgit.git/commitdiff
Flush the pack header as soon as its ready 19/1219/3
authorShawn O. Pearce <spearce@spearce.org>
Mon, 2 Aug 2010 17:17:21 +0000 (10:17 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Sat, 21 Aug 2010 00:41:27 +0000 (17:41 -0700)
When the output stream is deeply buffered (e.g. 1 MiB or more in
an HTTP servlet on some containers) trying to kick out the header
earlier will prevent the client from stalling hard while the first
1 MiB is received and it can process the pack header.  Forcing a
flush here lets the client see the header and start its progress
monitor for "Receiving objects: (1/N)" so the user knows there
is still activity occurring, even though the buffering may cause
there to be some lag as the buffer fills up on the sending side.

Change-Id: I3edf39e8f703fe87a738dc236d426b194db85e3a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java

index df5594cf4443faca4f1cd21c01e1a118ca51531e..1bb11c3a0d88f46fe3ed97042e1632bed9522a81 100644 (file)
@@ -487,6 +487,7 @@ public class PackWriter {
                int objCnt = getObjectsNumber();
                writeMonitor.beginTask(JGitText.get().writingObjects, objCnt);
                out.writeFileHeader(PACK_VERSION_GENERATED, objCnt);
+               out.flush();
                writeObjects(writeMonitor, out);
                writeChecksum(out);