[PATCH] give priority to progress messages

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Nicolas Pitre
Date: Wednesday, November 11, 2009 - 3:24 pm

In theory it is possible for sideband channel #2 to be delayed if
pack data is quick to come up for sideband channel #1.  And because
data for channel #2 is read only 128 bytes at a time while pack data
is read 8192 bytes at a time, it is possible for many pack blocks to
be sent to the client before the progress message fifo is emptied,
making the situation even worse.  This would result in totally garbled
progress display on the client's console as local progress gets mixed
with partial remote progress lines.

Let's prevent such situations by giving transmission priority to 
progress messages over pack data at all times.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
---

On Wed, 11 Nov 2009, Petr Baudis wrote:


I don't see why the issue couldn't happen with latest git as well.
This patch however would plug any possibilities for this to happen again 
though.

diff --git a/builtin-upload-archive.c b/builtin-upload-archive.c
index c4cd1e1..29446e8 100644
--- a/builtin-upload-archive.c
+++ b/builtin-upload-archive.c
@@ -132,7 +132,6 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
 
 	while (1) {
 		struct pollfd pfd[2];
-		ssize_t processed[2] = { 0, 0 };
 		int status;
 
 		pfd[0].fd = fd1[0];
@@ -147,15 +146,14 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
 			}
 			continue;
 		}
-		if (pfd[0].revents & POLLIN)
-			/* Data stream ready */
-			processed[0] = process_input(pfd[0].fd, 1);
 		if (pfd[1].revents & POLLIN)
 			/* Status stream ready */
-			processed[1] = process_input(pfd[1].fd, 2);
-		/* Always finish to read data when available */
-		if (processed[0] || processed[1])
-			continue;
+			if (process_input(pfd[1].fd, 2))
+				continue;
+		if (pfd[0].revents & POLLIN)
+			/* Data stream ready */
+			if (process_input(pfd[0].fd, 1))
+				continue;
 
 		if (waitpid(writer, &status, 0) < 0)
 			error_clnt("%s", lostchild);
diff --git a/upload-pack.c b/upload-pack.c
index 70badcf..6bfb500 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -310,6 +310,23 @@ static void create_pack_file(void)
 			}
 			continue;
 		}
+		if (0 <= pe && (pfd[pe].revents & (POLLIN|POLLHUP))) {
+			/* Status ready; we ship that in the side-band
+			 * or dump to the standard error.
+			 */
+			sz = xread(pack_objects.err, progress,
+				  sizeof(progress));
+			if (0 < sz)
+				send_client_data(2, progress, sz);
+			else if (sz == 0) {
+				close(pack_objects.err);
+				pack_objects.err = -1;
+			}
+			else
+				goto fail;
+			/* give priority to status messages */
+			continue;
+		}
 		if (0 <= pu && (pfd[pu].revents & (POLLIN|POLLHUP))) {
 			/* Data ready; we keep the last byte to ourselves
 			 * in case we detect broken rev-list, so that we
@@ -347,21 +364,6 @@ static void create_pack_file(void)
 			if (sz < 0)
 				goto fail;
 		}
-		if (0 <= pe && (pfd[pe].revents & (POLLIN|POLLHUP))) {
-			/* Status ready; we ship that in the side-band
-			 * or dump to the standard error.
-			 */
-			sz = xread(pack_objects.err, progress,
-				  sizeof(progress));
-			if (0 < sz)
-				send_client_data(2, progress, sz);
-			else if (sz == 0) {
-				close(pack_objects.err);
-				pack_objects.err = -1;
-			}
-			else
-				goto fail;
-		}
 	}
 
 	if (finish_command(&pack_objects)) {
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
excerpts from tomorrow's &quot;What's cooking&quot; draft, Junio C Hamano, (Wed Nov 11, 2:34 am)
Re: excerpts from tomorrow's &quot;What's cooking&quot; draft, Sverre Rabbelier, (Wed Nov 11, 10:57 am)
Re: excerpts from tomorrow's &quot;What's cooking&quot; draft, Nicolas Sebrecht, (Wed Nov 11, 11:42 am)
Re: excerpts from tomorrow's &quot;What's cooking&quot; draft, Daniel Barkalow, (Wed Nov 11, 11:45 am)
Re: excerpts from tomorrow's &quot;What's cooking&quot; draft, Nicolas Sebrecht, (Wed Nov 11, 2:26 pm)
ks/precompute-completion, Jonathan Nieder, (Wed Nov 11, 3:08 pm)
[PATCH] give priority to progress messages, Nicolas Pitre, (Wed Nov 11, 3:24 pm)
Re: ks/precompute-completion, Stephen Boyd, (Thu Nov 12, 11:40 pm)
Re: ks/precompute-completion, Jonathan Nieder, (Fri Nov 13, 12:06 am)
Re: ks/precompute-completion, Stephen Boyd, (Fri Nov 13, 12:12 am)
[PATCH] Speed up bash completion loading, Jonathan Nieder, (Fri Nov 13, 1:50 am)
Re: [PATCH] Speed up bash completion loading, Jonathan Nieder, (Fri Nov 13, 2:03 am)
Re: [PATCH] Speed up bash completion loading, Jonathan Nieder, (Fri Nov 13, 3:29 am)
Re: [PATCH] Speed up bash completion loading, Stephen Boyd, (Fri Nov 13, 1:43 pm)
Re: [PATCH] Speed up bash completion loading, Jonathan Nieder, (Sat Nov 14, 3:35 am)
Re: [PATCH] Speed up bash completion loading, Jonathan Nieder, (Sat Nov 14, 4:01 am)
Re: [PATCH] Speed up bash completion loading, SZEDER =?iso-8859-1? ..., (Sat Nov 14, 7:43 am)
Re: [PATCH] Speed up bash completion loading, Jonathan Nieder, (Sat Nov 14, 12:33 pm)
Re: [PATCH] Speed up bash completion loading, Stephen Boyd, (Sat Nov 14, 4:46 pm)
Re: excerpts from tomorrow's &quot;What's cooking&quot; draft, Sverre Rabbelier, (Sat Nov 14, 7:07 pm)
Re: [PATCH] Speed up bash completion loading, Jonathan Nieder, (Sat Nov 14, 11:50 pm)
Re: [PATCH] Speed up bash completion loading, Junio C Hamano, (Sun Nov 15, 2:05 am)
[PATCH v2] Speed up bash completion loading, Jonathan Nieder, (Sun Nov 15, 3:29 am)
Re: [PATCH v2] Speed up bash completion loading, Shawn O. Pearce, (Sun Nov 15, 6:55 pm)
Re: [PATCH v2] Speed up bash completion loading, Stephen Boyd, (Mon Nov 16, 1:28 am)
[PATCH v3] Speed up bash completion loading, Jonathan Nieder, (Tue Nov 17, 5:49 pm)
Re: [PATCH v3] Speed up bash completion loading, Shawn O. Pearce, (Tue Nov 17, 5:59 pm)