jgit: upload-pack: Force an fd flush after receiving flush pkt from client
PATCH 1/1 jgit: upload-pack: Force an fd flush after receiving flush pkt from client
--- .../src/org/spearce/jgit/transport/UploadPack.java | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java +1 -2
@@ -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)) {
@@ -372,7 +372,6 @@ private void negotiate() throws IOException { } else if (line.equals("done")) { if (commonBase.isEmpty()) pckOut.writeString("NAK\n"); - else if (multiAck) pckOut.writeString("ACK " + last.name() + "\n"); break;
Signature · 1 line
1.6.2
Shawn O. Pearce
Appliedorg.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java private void negotiate() throws IOException { · line 357
Quoted 13 lines · Dima Zavin
org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java +1
-1@@ -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.
---
Signature · 1 line
Shawn.