{"thread":{"id":"18326","subject":"[PATCH] jgit: upload-pack: Force an fd flush after receiving flush pkt from client","startedAt":"2009-03-16T17:34:24Z","lastAt":"2009-03-16T20:05:15Z","messageCount":2,"participants":["Dima Zavin","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"108105","messageId":"1237224864-15649-1-git-send-email-dima@android.com","threadId":"18326","inReplyTo":null,"subject":"[PATCH] jgit: upload-pack: Force an fd flush after receiving flush pkt from client","fromName":"Dima Zavin","fromEmail":"dima@android.com","sentAt":"2009-03-16T17:34:24Z","receivedAt":"2009-03-16T17:34:24Z","isPatch":true,"sender":{"key":"dima@android.com","avatar":null},"body":"Signed-off-by: Dima Zavin <dima@android.com>\n---\n .../src/org/spearce/jgit/transport/UploadPack.java |    3 +--\n 1 files changed, 1 insertions(+), 2 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java\nindex 71acda1..80c154b 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java\n@@ -351,7 +351,7 @@ private void negotiate() throws IOException {\n \t\t\tif (line.length() == 0) {\n \t\t\t\tif (commonBase.isEmpty() || multiAck)\n \t\t\t\t\tpckOut.writeString(\"NAK\\n\");\n-\n+\t\t\t\tpckOut.flush();\n \t\t\t} else if (line.startsWith(\"have \") && line.length() == 45) {\n \t\t\t\tfinal ObjectId id = ObjectId.fromString(line.substring(5));\n \t\t\t\tif (matchHave(id)) {\n@@ -372,7 +372,6 @@ private void negotiate() throws IOException {\n \t\t\t} else if (line.equals(\"done\")) {\n \t\t\t\tif (commonBase.isEmpty())\n \t\t\t\t\tpckOut.writeString(\"NAK\\n\");\n-\n \t\t\t\telse if (multiAck)\n \t\t\t\t\tpckOut.writeString(\"ACK \" + last.name() + \"\\n\");\n \t\t\t\tbreak;\n-- \n1.6.2\n"},{"id":"108117","messageId":"20090316200515.GQ22920@spearce.org","threadId":"18326","inReplyTo":"1237224864-15649-1-git-send-email-dima@android.com","subject":"Re: [PATCH] jgit: upload-pack: Force an fd flush after receiving flush pkt from client","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-03-16T20:05:15Z","receivedAt":"2009-03-16T20:05:15Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Dima Zavin <dima@android.com> wrote:\n> diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java\n> index 71acda1..80c154b 100644\n> --- a/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java\n> +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/UploadPack.java\n> @@ -351,7 +351,7 @@ private void negotiate() throws IOException {\n>  \t\t\tif (line.length() == 0) {\n>  \t\t\t\tif (commonBase.isEmpty() || multiAck)\n>  \t\t\t\t\tpckOut.writeString(\"NAK\\n\");\n> -\n> +\t\t\t\tpckOut.flush();\n>  \t\t\t} else if (line.startsWith(\"have \") && line.length() == 45) {\n>  \t\t\t\tfinal ObjectId id = ObjectId.fromString(line.substring(5));\n>  \t\t\t\tif (matchHave(id)) {\n\nApplied, but with this more verbose commit message:\n\n--8<--\nupload-pack: Force an fd flush after receiving flush pkt from client\n\nThe client is blocked waiting for an ACK or NAK line from the server.\nIf we don't call flush() here there is a very good chance the\nACK/NAK is stuck in our stream buffer within the JRE, and doesn't\nmake it into the kernel's TCP buffer.  This causes the server to\nwait for more have lines, and the client to wait for the ACK/NAK,\nand the entire thing just deadlocks.\n\nWe flush anytime we see a pkt-line flush command, as there may be\nbuffered ACK lines from prior evaulations that need to be sent to\nthe waiting client.\n\nSigned-off-by: Dima Zavin <dima@android.com>\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n-- \nShawn.\n"}]}