Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
remote-curl: define struct for CURLOPT_WRITEFUNCTION
author
Masaya Suzuki
<masayasuzuki@google.com>
Thu, 10 Jan 2019 19:33:48 +0000
(11:33 -0800)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 10 Jan 2019 23:00:56 +0000
(15:00 -0800)
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>
remote-curl.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
e6cf87b
)
diff --git
a/remote-curl.c
b/remote-curl.c
index d8eda2380a31fc28b903772a854f444296ab8e22..d4673b6e8ccab241072b5577d914612acf675b04 100644
(file)
--- a/
remote-curl.c
+++ b/
remote-curl.c
@@
-545,14
+545,22
@@
static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)
}
#endif
}
#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;
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)
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;
}
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;
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
/* 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
@@
static int post_rpc(struct rpc_state *rpc)
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in);
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;
rpc->any_written = 0;