summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasaya Suzuki <masayasuzuki@google.com>2019-01-10 11:33:48 -0800
committerJunio C Hamano <gitster@pobox.com>2019-01-10 15:00:56 -0800
commitcf2fb92b00df0594aac2176b524db45b62795a38 (patch)
tree42a4be041df619c7743c1c8ce097ce02a4ee612d
parente6cf87b12d3b85b31637c865bbfaed62c3e59e94 (diff)
downloadgit-cf2fb92b00df0594aac2176b524db45b62795a38.tar.gz
git-cf2fb92b00df0594aac2176b524db45b62795a38.tar.xz
remote-curl: define struct for CURLOPT_WRITEFUNCTION
In order to pass more values for rpc_in, define a struct and pass it as an additional value. Signed-off-by: Masaya Suzuki <masayasuzuki@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--remote-curl.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/remote-curl.c b/remote-curl.c
index d8eda2380..d4673b6e8 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -545,14 +545,22 @@ static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)
}
#endif
+struct rpc_in_data {
+ struct rpc_state *rpc;
+};
+
+/*
+ * A callback for CURLOPT_WRITEFUNCTION. The return value is the bytes consumed
+ * from ptr.
+ */
static size_t rpc_in(char *ptr, size_t eltsize,
size_t nmemb, void *buffer_)
{
size_t size = eltsize * nmemb;
- struct rpc_state *rpc = buffer_;
+ struct rpc_in_data *data = buffer_;
if (size)
- rpc->any_written = 1;
- write_or_die(rpc->in, ptr, size);
+ data->rpc->any_written = 1;
+ write_or_die(data->rpc->in, ptr, size);
return size;
}
@@ -632,6 +640,7 @@ static int post_rpc(struct rpc_state *rpc)
size_t gzip_size = 0;
int err, large_request = 0;
int needs_100_continue = 0;
+ struct rpc_in_data rpc_in_data;
/* Try to load the entire request, if we can fit it into the
* allocated buffer space we can use HTTP/1.0 and avoid the
@@ -764,7 +773,8 @@ retry:
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in);
- curl_easy_setopt(slot->curl, CURLOPT_FILE, rpc);
+ rpc_in_data.rpc = rpc;
+ curl_easy_setopt(slot->curl, CURLOPT_FILE, &rpc_in_data);
rpc->any_written = 0;