summaryrefslogtreecommitdiffstats
path: root/Utilities/cmcurl/lib/pingpong.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-02-03 16:55:06 (GMT)
committerBrad King <brad.king@kitware.com>2021-02-03 16:55:06 (GMT)
commit426ef61cc8d850ad6877d0598a9917ce9a4f2b20 (patch)
tree139e0e0af11012c1cd5e9c89d90305bf6d68e916 /Utilities/cmcurl/lib/pingpong.c
parent0341888c006c19d0057017231ed43279d53e6034 (diff)
parent076b3219f58ca16afa52fe095019a05537ade0f3 (diff)
downloadCMake-426ef61cc8d850ad6877d0598a9917ce9a4f2b20.zip
CMake-426ef61cc8d850ad6877d0598a9917ce9a4f2b20.tar.gz
CMake-426ef61cc8d850ad6877d0598a9917ce9a4f2b20.tar.bz2
Merge branch 'upstream-curl' into update-curl
* upstream-curl: curl 2021-02-03 (2f33be81)
Diffstat (limited to 'Utilities/cmcurl/lib/pingpong.c')
-rw-r--r--Utilities/cmcurl/lib/pingpong.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/Utilities/cmcurl/lib/pingpong.c b/Utilities/cmcurl/lib/pingpong.c
index 5d6109a..4811739 100644
--- a/Utilities/cmcurl/lib/pingpong.c
+++ b/Utilities/cmcurl/lib/pingpong.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -44,10 +44,10 @@
/* Returns timeout in ms. 0 or negative number means the timeout has already
triggered */
-timediff_t Curl_pp_state_timeout(struct pingpong *pp, bool disconnecting)
+timediff_t Curl_pp_state_timeout(struct Curl_easy *data,
+ struct pingpong *pp, bool disconnecting)
{
- struct connectdata *conn = pp->conn;
- struct Curl_easy *data = conn->data;
+ struct connectdata *conn = data->conn;
timediff_t timeout_ms; /* in milliseconds */
timediff_t response_time = (data->set.server_response_timeout)?
data->set.server_response_timeout: pp->response_time;
@@ -77,15 +77,15 @@ timediff_t Curl_pp_state_timeout(struct pingpong *pp, bool disconnecting)
/*
* Curl_pp_statemach()
*/
-CURLcode Curl_pp_statemach(struct pingpong *pp, bool block,
+CURLcode Curl_pp_statemach(struct Curl_easy *data,
+ struct pingpong *pp, bool block,
bool disconnecting)
{
- struct connectdata *conn = pp->conn;
+ struct connectdata *conn = data->conn;
curl_socket_t sock = conn->sock[FIRSTSOCKET];
int rc;
timediff_t interval_ms;
- timediff_t timeout_ms = Curl_pp_state_timeout(pp, disconnecting);
- struct Curl_easy *data = conn->data;
+ timediff_t timeout_ms = Curl_pp_state_timeout(data, pp, disconnecting);
CURLcode result = CURLE_OK;
if(timeout_ms <= 0) {
@@ -117,7 +117,7 @@ CURLcode Curl_pp_statemach(struct pingpong *pp, bool block,
if(block) {
/* if we didn't wait, we don't have to spend time on this now */
- if(Curl_pgrsUpdate(conn))
+ if(Curl_pgrsUpdate(data))
result = CURLE_ABORTED_BY_CALLBACK;
else
result = Curl_speedcheck(data, Curl_now());
@@ -131,17 +131,17 @@ CURLcode Curl_pp_statemach(struct pingpong *pp, bool block,
result = CURLE_OUT_OF_MEMORY;
}
else if(rc)
- result = pp->statemach_act(conn);
+ result = pp->statemachine(data, data->conn);
return result;
}
/* initialize stuff to prepare for reading a fresh new response */
-void Curl_pp_init(struct pingpong *pp)
+void Curl_pp_init(struct Curl_easy *data, struct pingpong *pp)
{
- struct connectdata *conn = pp->conn;
+ DEBUGASSERT(data);
pp->nread_resp = 0;
- pp->linestart_resp = conn->data->state.buffer;
+ pp->linestart_resp = data->state.buffer;
pp->pending_resp = TRUE;
pp->response = Curl_now(); /* start response time-out now! */
}
@@ -162,7 +162,8 @@ void Curl_pp_setup(struct pingpong *pp)
*
* made to never block
*/
-CURLcode Curl_pp_vsendf(struct pingpong *pp,
+CURLcode Curl_pp_vsendf(struct Curl_easy *data,
+ struct pingpong *pp,
const char *fmt,
va_list args)
{
@@ -170,8 +171,7 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
size_t write_len;
char *s;
CURLcode result;
- struct connectdata *conn = pp->conn;
- struct Curl_easy *data;
+ struct connectdata *conn = data->conn;
#ifdef HAVE_GSSAPI
enum protection_level data_sec;
@@ -184,7 +184,6 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
if(!conn)
/* can't send without a connection! */
return CURLE_SEND_ERROR;
- data = conn->data;
Curl_dyn_reset(&pp->sendbuf);
result = Curl_dyn_vaddf(&pp->sendbuf, fmt, args);
@@ -198,7 +197,7 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
write_len = Curl_dyn_len(&pp->sendbuf);
s = Curl_dyn_ptr(&pp->sendbuf);
- Curl_pp_init(pp);
+ Curl_pp_init(data, pp);
result = Curl_convert_to_network(data, s, write_len);
/* Curl_convert_to_network calls failf if unsuccessful */
@@ -208,7 +207,7 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
#ifdef HAVE_GSSAPI
conn->data_prot = PROT_CMD;
#endif
- result = Curl_write(conn, conn->sock[FIRSTSOCKET], s, write_len,
+ result = Curl_write(data, conn->sock[FIRSTSOCKET], s, write_len,
&bytes_written);
if(result)
return result;
@@ -246,14 +245,14 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
*
* made to never block
*/
-CURLcode Curl_pp_sendf(struct pingpong *pp,
+CURLcode Curl_pp_sendf(struct Curl_easy *data, struct pingpong *pp,
const char *fmt, ...)
{
CURLcode result;
va_list ap;
va_start(ap, fmt);
- result = Curl_pp_vsendf(pp, fmt, ap);
+ result = Curl_pp_vsendf(data, pp, fmt, ap);
va_end(ap);
@@ -265,7 +264,8 @@ CURLcode Curl_pp_sendf(struct pingpong *pp,
*
* Reads a piece of a server response.
*/
-CURLcode Curl_pp_readresp(curl_socket_t sockfd,
+CURLcode Curl_pp_readresp(struct Curl_easy *data,
+ curl_socket_t sockfd,
struct pingpong *pp,
int *code, /* return the server code if done */
size_t *size) /* size of the response */
@@ -274,8 +274,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
bool keepon = TRUE;
ssize_t gotbytes;
char *ptr;
- struct connectdata *conn = pp->conn;
- struct Curl_easy *data = conn->data;
+ struct connectdata *conn = data->conn;
char * const buf = data->state.buffer;
CURLcode result = CURLE_OK;
@@ -315,7 +314,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
#endif
DEBUGASSERT((ptr + data->set.buffer_size - pp->nread_resp) <=
(buf + data->set.buffer_size + 1));
- result = Curl_read(conn, sockfd, ptr,
+ result = Curl_read(data, sockfd, ptr,
data->set.buffer_size - pp->nread_resp,
&gotbytes);
#ifdef HAVE_GSSAPI
@@ -371,12 +370,12 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
* for "headers". The response lines can be seen as a kind of
* headers.
*/
- result = Curl_client_write(conn, CLIENTWRITE_HEADER,
+ result = Curl_client_write(data, CLIENTWRITE_HEADER,
pp->linestart_resp, perline);
if(result)
return result;
- if(pp->endofresp(conn, pp->linestart_resp, perline, code)) {
+ if(pp->endofresp(data, conn, pp->linestart_resp, perline, code)) {
/* This is the end of the last line, copy the last line to the
start of the buffer and null-terminate, for old times sake */
size_t n = ptr - pp->linestart_resp;
@@ -456,10 +455,10 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
return result;
}
-int Curl_pp_getsock(struct pingpong *pp,
- curl_socket_t *socks)
+int Curl_pp_getsock(struct Curl_easy *data,
+ struct pingpong *pp, curl_socket_t *socks)
{
- struct connectdata *conn = pp->conn;
+ struct connectdata *conn = data->conn;
socks[0] = conn->sock[FIRSTSOCKET];
if(pp->sendleft) {
@@ -471,13 +470,14 @@ int Curl_pp_getsock(struct pingpong *pp,
return GETSOCK_READSOCK(0);
}
-CURLcode Curl_pp_flushsend(struct pingpong *pp)
+CURLcode Curl_pp_flushsend(struct Curl_easy *data,
+ struct pingpong *pp)
{
/* we have a piece of a command still left to send */
- struct connectdata *conn = pp->conn;
+ struct connectdata *conn = data->conn;
ssize_t written;
curl_socket_t sock = conn->sock[FIRSTSOCKET];
- CURLcode result = Curl_write(conn, sock, pp->sendthis + pp->sendsize -
+ CURLcode result = Curl_write(data, sock, pp->sendthis + pp->sendsize -
pp->sendleft, pp->sendleft, &written);
if(result)
return result;