summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 958c24b)
raw | patch | inline | side by side (parent: 958c24b)
author | Junio C Hamano <junkio@cox.net> | |
Sun, 10 Sep 2006 23:27:08 +0000 (16:27 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 10 Sep 2006 23:27:08 +0000 (16:27 -0700) |
The original side-band support added to the upload-pack protocol used the
default 1000-byte packet length. The pkt-line format allows up to 64k, so
prepare the receiver for the maximum size, and have the uploader and
downloader negotiate if larger packet length is allowed.
Signed-off-by: Junio C Hamano <junkio@cox.net>
default 1000-byte packet length. The pkt-line format allows up to 64k, so
prepare the receiver for the maximum size, and have the uploader and
downloader negotiate if larger packet length is allowed.
Signed-off-by: Junio C Hamano <junkio@cox.net>
fetch-clone.c | patch | blob | history | |
fetch-pack.c | patch | blob | history | |
sideband.h | patch | blob | history | |
upload-pack.c | patch | blob | history |
diff --git a/fetch-clone.c b/fetch-clone.c
index b62feac17d781f1223e6d01fa0b007afcccf909b..b632ca0438b378944b37a7d64fd508ea3f7f470f 100644 (file)
--- a/fetch-clone.c
+++ b/fetch-clone.c
die("%s: unable to fork off sideband demultiplexer", me);
if (!side_pid) {
/* subprocess */
- char buf[DEFAULT_PACKET_MAX];
+ char buf[LARGE_PACKET_MAX];
close(fd[0]);
if (xd[0] != xd[1])
diff --git a/fetch-pack.c b/fetch-pack.c
index 377feded1ccafdece86499d1917d297145fd28ac..1b2d6ee20d16d03a59d2cd2aafb46e9a03c492b0 100644 (file)
--- a/fetch-pack.c
+++ b/fetch-pack.c
}
if (!fetching)
- packet_write(fd[1], "want %s%s%s%s\n",
+ packet_write(fd[1], "want %s%s%s%s%s\n",
sha1_to_hex(remote),
(multi_ack ? " multi_ack" : ""),
- (use_sideband ? " side-band" : ""),
+ (use_sideband == 2 ? " side-band-64k" : ""),
+ (use_sideband == 1 ? " side-band" : ""),
(use_thin_pack ? " thin-pack" : ""));
else
packet_write(fd[1], "want %s\n", sha1_to_hex(remote));
fprintf(stderr, "Server supports multi_ack\n");
multi_ack = 1;
}
- if (server_supports("side-band")) {
+ if (server_supports("side-band-64k")) {
+ if (verbose)
+ fprintf(stderr, "Server supports side-band-64k\n");
+ use_sideband = 2;
+ }
+ else if (server_supports("side-band")) {
if (verbose)
fprintf(stderr, "Server supports side-band\n");
use_sideband = 1;
diff --git a/sideband.h b/sideband.h
index c645cf2c521f3153d353ab0466607adeaa1d4498..4872106fa0881a4ccb6fbaf6343d63bd31effd8c 100644 (file)
--- a/sideband.h
+++ b/sideband.h
#define SIDEBAND_REMOTE_ERROR -1
#define DEFAULT_PACKET_MAX 1000
+#define LARGE_PACKET_MAX 65520
int recv_sideband(const char *me, int in_stream, int out, int err, char *, int);
ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max);
diff --git a/upload-pack.c b/upload-pack.c
index 1f2f7f75e5c10f0beb708b282a911d52da77b60c..b673d8cb9748de0758d1c5269178e70a018f43a1 100644 (file)
--- a/upload-pack.c
+++ b/upload-pack.c
static struct object_array have_obj;
static struct object_array want_obj;
static unsigned int timeout;
+/* 0 for no sideband,
+ * otherwise maximum packet size (up to 65520 bytes).
+ */
static int use_sideband;
static void reset_timeout(void)
static ssize_t send_client_data(int fd, const char *data, ssize_t sz)
{
if (use_sideband)
- return send_sideband(1, fd, data, sz, DEFAULT_PACKET_MAX);
-
+ return send_sideband(1, fd, data, sz, use_sideband);
if (fd == 3)
/* emergency quit */
fd = 2;
multi_ack = 1;
if (strstr(line+45, "thin-pack"))
use_thin_pack = 1;
- if (strstr(line+45, "side-band"))
- use_sideband = 1;
+ if (strstr(line+45, "side-band-64k"))
+ use_sideband = LARGE_PACKET_MAX;
+ else if (strstr(line+45, "side-band"))
+ use_sideband = DEFAULT_PACKET_MAX;
/* We have sent all our refs already, and the other end
* should have chosen out of them; otherwise they are
static int send_ref(const char *refname, const unsigned char *sha1)
{
- static const char *capabilities = "multi_ack thin-pack side-band";
+ static const char *capabilities = "multi_ack thin-pack side-band side-band-64k";
struct object *o = parse_object(sha1);
if (!o)