Merge pull request #6205 from ccstolley/ccs_fix_http_push_timeout push: Prepare pack before sending pack header.
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
diff --git a/src/pack-objects.c b/src/pack-objects.c
index 35c1d55..1aa6731 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -1308,7 +1308,7 @@ static int ll_find_deltas(git_packbuilder *pb, git_pobject **list,
#define ll_find_deltas(pb, l, ls, w, d) find_deltas(pb, l, &ls, w, d)
#endif
-static int prepare_pack(git_packbuilder *pb)
+int git_packbuilder__prepare(git_packbuilder *pb)
{
git_pobject **delta_list;
size_t i, n = 0;
@@ -1353,7 +1353,7 @@ static int prepare_pack(git_packbuilder *pb)
return 0;
}
-#define PREPARE_PACK if (prepare_pack(pb) < 0) { return -1; }
+#define PREPARE_PACK if (git_packbuilder__prepare(pb) < 0) { return -1; }
int git_packbuilder_foreach(git_packbuilder *pb, int (*cb)(void *buf, size_t size, void *payload), void *payload)
{
diff --git a/src/pack-objects.h b/src/pack-objects.h
index 53c9f5d..2faa3ec 100644
--- a/src/pack-objects.h
+++ b/src/pack-objects.h
@@ -100,5 +100,7 @@ struct git_packbuilder {
};
int git_packbuilder__write_buf(git_str *buf, git_packbuilder *pb);
+int git_packbuilder__prepare(git_packbuilder *pb);
+
#endif
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 0610281..adfc304 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -1036,6 +1036,10 @@ int git_smart__push(git_transport *transport, git_push *push)
}
}
+ /* prepare pack before sending pack header to avoid timeouts */
+ if (need_pack && ((error = git_packbuilder__prepare(push->pb))) < 0)
+ goto done;
+
if ((error = git_smart__get_push_stream(t, &packbuilder_payload.stream)) < 0 ||
(error = gen_pktline(&pktline, push)) < 0 ||
(error = packbuilder_payload.stream->write(packbuilder_payload.stream, git_str_cstr(&pktline), git_str_len(&pktline))) < 0)