http.postbuffer: allow full range of ssize_t values
Unfortunately, in order to push some large repos where a server does not support chunked encoding, the http postbuffer must sometimes exceed two gigabytes. On a 64-bit system, this is OK: we just malloc a larger buffer. This means that we need to use CURLOPT_POSTFIELDSIZE_LARGE to set the buffer size. Signed-off-by: David Turner <dturner@twosigma.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
b14f27f917
commit
37ee680d9b
@ -531,6 +531,12 @@ static int probe_rpc(struct rpc_state *rpc, struct slot_results *results)
|
||||
return err;
|
||||
}
|
||||
|
||||
static curl_off_t xcurl_off_t(ssize_t len) {
|
||||
if (len > maximum_signed_value_of_type(curl_off_t))
|
||||
die("cannot handle pushes this big");
|
||||
return (curl_off_t) len;
|
||||
}
|
||||
|
||||
static int post_rpc(struct rpc_state *rpc)
|
||||
{
|
||||
struct active_request_slot *slot;
|
||||
@ -614,7 +620,7 @@ retry:
|
||||
* and we just need to send it.
|
||||
*/
|
||||
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, gzip_body);
|
||||
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, gzip_size);
|
||||
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE_LARGE, xcurl_off_t(gzip_size));
|
||||
|
||||
} else if (use_gzip && 1024 < rpc->len) {
|
||||
/* The client backend isn't giving us compressed data so
|
||||
@ -645,7 +651,7 @@ retry:
|
||||
|
||||
headers = curl_slist_append(headers, "Content-Encoding: gzip");
|
||||
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, gzip_body);
|
||||
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, gzip_size);
|
||||
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE_LARGE, xcurl_off_t(gzip_size));
|
||||
|
||||
if (options.verbosity > 1) {
|
||||
fprintf(stderr, "POST %s (gzip %lu to %lu bytes)\n",
|
||||
@ -658,7 +664,7 @@ retry:
|
||||
* more normal Content-Length approach.
|
||||
*/
|
||||
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, rpc->buf);
|
||||
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE, rpc->len);
|
||||
curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDSIZE_LARGE, xcurl_off_t(rpc->len));
|
||||
if (options.verbosity > 1) {
|
||||
fprintf(stderr, "POST %s (%lu bytes)\n",
|
||||
rpc->service_name, (unsigned long)rpc->len);
|
||||
|
||||
Reference in New Issue
Block a user