pkt: get rid of the chunked support It was a bad idea. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
diff --git a/src/netops.c b/src/netops.c
index 5d17e17..dad296a 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -152,20 +152,6 @@ int gitno_close(GIT_SOCKET s)
}
#endif
-int gitno_send_chunk_size(int s, size_t len)
-{
- char str[8] = {0};
- int ret;
-
- ret = p_snprintf(str, sizeof(str), "%zx\r\n", len);
- if (ret >= (int) sizeof(str)) {
- return git__throw(GIT_ESHORTBUFFER, "Your number is too big");
- }
-
- return gitno_send(s, str, ret, 0 /* TODO: MSG_MORE */);
-}
-
-
int gitno_select_in(gitno_buffer *buf, long int sec, long int usec)
{
fd_set fds;
diff --git a/src/pkt.c b/src/pkt.c
index 7aa225c..be850bc 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -268,16 +268,10 @@ int git_pkt_buffer_flush(git_buf *buf)
return git_buf_oom(buf) ? GIT_ENOMEM : GIT_SUCCESS;
}
-int git_pkt_send_flush(int s, int chunked)
+int git_pkt_send_flush(int s)
{
char flush[] = "0000";
- int error;
- if (chunked) {
- error = gitno_send_chunk_size(s, strlen(flush));
- if (error < GIT_SUCCESS)
- return git__rethrow(error, "Failed to send chunk size");
- }
return gitno_send(s, flush, strlen(flush), 0);
}
@@ -356,7 +350,7 @@ int git_pkt_buffer_wants(git_headarray *refs, git_transport_caps *caps, git_buf
return git_pkt_buffer_flush(buf);
}
-int git_pkt_send_wants(git_headarray *refs, git_transport_caps *caps, int fd, int chunked)
+int git_pkt_send_wants(git_headarray *refs, git_transport_caps *caps, int fd)
{
unsigned int i = 0;
int error = GIT_SUCCESS;
@@ -391,17 +385,12 @@ int git_pkt_send_wants(git_headarray *refs, git_transport_caps *caps, int fd, in
continue;
git_oid_fmt(buf + strlen(WANT_PREFIX), &head->oid);
- if (chunked) {
- error = gitno_send_chunk_size(fd, strlen(buf));
- if (error < GIT_SUCCESS)
- return git__rethrow(error, "Failed to send want chunk size");
- }
error = gitno_send(fd, buf, strlen(buf), 0);
if (error < GIT_SUCCESS)
return git__rethrow(error, "Failed to send want pkt");
}
- return git_pkt_send_flush(fd, chunked);
+ return git_pkt_send_flush(fd);
}
#define HAVE_PREFIX "0032have "
@@ -416,16 +405,10 @@ int git_pkt_buffer_have(git_oid *oid, git_buf *buf)
return git_buf_oom(buf) ? GIT_ENOMEM : GIT_SUCCESS;
}
-int git_pkt_send_have(git_oid *oid, int fd, int chunked)
+int git_pkt_send_have(git_oid *oid, int fd)
{
char buf[] = "0032have 0000000000000000000000000000000000000000\n";
- int error;
- if (chunked) {
- error = gitno_send_chunk_size(fd, strlen(buf));
- if (error < GIT_SUCCESS)
- return git__rethrow(error, "Failed to send chunk size");
- }
git_oid_fmt(buf + strlen(HAVE_PREFIX), oid);
return gitno_send(fd, buf, strlen(buf), 0);
}
@@ -438,15 +421,9 @@ int git_pkt_buffer_done(git_buf *buf)
return git_buf_oom(buf) ? GIT_ENOMEM : GIT_SUCCESS;
}
-int git_pkt_send_done(int fd, int chunked)
+int git_pkt_send_done(int fd)
{
char buf[] = "0009done\n";
- int error;
- if (chunked) {
- error = gitno_send_chunk_size(fd, strlen(buf));
- if (error < GIT_SUCCESS)
- return git__rethrow(error, "Failed to send chunk size");
- }
return gitno_send(fd, buf, strlen(buf), 0);
}
diff --git a/src/pkt.h b/src/pkt.h
index 44c36b4..88711f2 100644
--- a/src/pkt.h
+++ b/src/pkt.h
@@ -65,13 +65,13 @@ typedef struct {
int git_pkt_parse_line(git_pkt **head, const char *line, const char **out, size_t len);
int git_pkt_buffer_flush(git_buf *buf);
-int git_pkt_send_flush(int s, int chunked);
+int git_pkt_send_flush(int s);
int git_pkt_buffer_done(git_buf *buf);
-int git_pkt_send_done(int s, int chunked);
+int git_pkt_send_done(int s);
int git_pkt_buffer_wants(git_headarray *refs, git_transport_caps *caps, git_buf *buf);
-int git_pkt_send_wants(git_headarray *refs, git_transport_caps *caps, int fd, int chunked);
+int git_pkt_send_wants(git_headarray *refs, git_transport_caps *caps, int fd);
int git_pkt_buffer_have(git_oid *oid, git_buf *buf);
-int git_pkt_send_have(git_oid *oid, int fd, int chunked);
+int git_pkt_send_have(git_oid *oid, int fd);
void git_pkt_free(git_pkt *pkt);
#endif
diff --git a/src/transport_git.c b/src/transport_git.c
index e4c5a07..e32b333 100644
--- a/src/transport_git.c
+++ b/src/transport_git.c
@@ -277,7 +277,7 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g
char buff[128];
gitno_buffer buf;
- error = git_pkt_send_wants(wants, &t->caps, t->socket, 0);
+ error = git_pkt_send_wants(wants, &t->caps, t->socket);
if (error < GIT_SUCCESS)
return git__rethrow(error, "Failed to send wants list");
@@ -322,12 +322,12 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g
*/
i = 0;
while ((error = git_revwalk_next(&oid, walk)) == GIT_SUCCESS) {
- error = git_pkt_send_have(&oid, t->socket, 1);
+ error = git_pkt_send_have(&oid, t->socket);
i++;
if (i % 20 == 0) {
const char *ptr = buf.data, *line_end;
git_pkt *pkt;
- git_pkt_send_flush(t->socket, 0);
+ git_pkt_send_flush(t->socket);
while (1) {
/* Wait for max. 1 second */
error = gitno_select_in(&buf, 1, 0);
@@ -373,8 +373,8 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g
error = GIT_SUCCESS;
done:
- git_pkt_send_flush(t->socket, 0);
- git_pkt_send_done(t->socket, 0);
+ git_pkt_send_flush(t->socket);
+ git_pkt_send_done(t->socket);
cleanup:
git_revwalk_free(walk);
@@ -385,14 +385,14 @@ static int git_send_flush(git_transport *transport)
{
transport_git *t = (transport_git *) transport;
- return git_pkt_send_flush(t->socket, 1);
+ return git_pkt_send_flush(t->socket);
}
static int git_send_done(git_transport *transport)
{
transport_git *t = (transport_git *) transport;
- return git_pkt_send_done(t->socket, 1);
+ return git_pkt_send_done(t->socket);
}
static int store_pack(char **out, gitno_buffer *buf, git_repository *repo)
@@ -492,7 +492,7 @@ static int git_close(git_transport *transport)
int error;
/* Can't do anything if there's an error, so don't bother checking */
- git_pkt_send_flush(t->socket, 0);
+ git_pkt_send_flush(t->socket);
error = gitno_close(t->socket);
if (error < 0)