summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/cfilters.c
diff options
context:
space:
mode:
authordartraiden <wowemuh@gmail.com>2024-09-11 21:49:43 +0300
committerdartraiden <wowemuh@gmail.com>2024-09-11 21:52:35 +0300
commitc36db68a5f58ec6c9135eff778b6e77c30e58088 (patch)
tree22eea126db82c50388c9f94cd683d6ec6f04e6cb /libs/libcurl/src/cfilters.c
parent02bb82c1c0a4031e7b2f5578370fa5acd620f8e1 (diff)
libcurl: update to 8.10.0
Diffstat (limited to 'libs/libcurl/src/cfilters.c')
-rw-r--r--libs/libcurl/src/cfilters.c75
1 files changed, 63 insertions, 12 deletions
diff --git a/libs/libcurl/src/cfilters.c b/libs/libcurl/src/cfilters.c
index d10c6c1ed0..7ec8f3a79f 100644
--- a/libs/libcurl/src/cfilters.c
+++ b/libs/libcurl/src/cfilters.c
@@ -45,6 +45,9 @@
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
#endif
+static void cf_cntrl_update_info(struct Curl_easy *data,
+ struct connectdata *conn);
+
#ifdef UNITTESTS
/* used by unit2600.c */
void Curl_cf_def_close(struct Curl_cfilter *cf, struct Curl_easy *data)
@@ -98,10 +101,11 @@ bool Curl_cf_def_data_pending(struct Curl_cfilter *cf,
}
ssize_t Curl_cf_def_send(struct Curl_cfilter *cf, struct Curl_easy *data,
- const void *buf, size_t len, CURLcode *err)
+ const void *buf, size_t len, bool eos,
+ CURLcode *err)
{
return cf->next?
- cf->next->cft->do_send(cf->next, data, buf, len, err) :
+ cf->next->cft->do_send(cf->next, data, buf, len, eos, err) :
CURLE_RECV_ERROR;
}
@@ -256,7 +260,8 @@ ssize_t Curl_cf_recv(struct Curl_easy *data, int num, char *buf,
}
ssize_t Curl_cf_send(struct Curl_easy *data, int num,
- const void *mem, size_t len, CURLcode *code)
+ const void *mem, size_t len, bool eos,
+ CURLcode *code)
{
struct Curl_cfilter *cf;
@@ -268,7 +273,7 @@ ssize_t Curl_cf_send(struct Curl_easy *data, int num,
cf = cf->next;
}
if(cf) {
- ssize_t nwritten = cf->cft->do_send(cf, data, mem, len, code);
+ ssize_t nwritten = cf->cft->do_send(cf, data, mem, len, eos, code);
DEBUGASSERT(nwritten >= 0 || *code);
DEBUGASSERT(nwritten < 0 || !*code || !len);
return nwritten;
@@ -379,10 +384,11 @@ void Curl_conn_cf_close(struct Curl_cfilter *cf, struct Curl_easy *data)
}
ssize_t Curl_conn_cf_send(struct Curl_cfilter *cf, struct Curl_easy *data,
- const void *buf, size_t len, CURLcode *err)
+ const void *buf, size_t len, bool eos,
+ CURLcode *err)
{
if(cf)
- return cf->cft->do_send(cf, data, buf, len, err);
+ return cf->cft->do_send(cf, data, buf, len, eos, err);
*err = CURLE_SEND_ERROR;
return -1;
}
@@ -416,9 +422,19 @@ CURLcode Curl_conn_connect(struct Curl_easy *data,
*done = cf->connected;
if(!*done) {
+ if(Curl_conn_needs_flush(data, sockindex)) {
+ DEBUGF(infof(data, "Curl_conn_connect(index=%d), flush", sockindex));
+ result = Curl_conn_flush(data, sockindex);
+ if(result && (result != CURLE_AGAIN))
+ return result;
+ }
+
result = cf->cft->do_connect(cf, data, blocking, done);
if(!result && *done) {
- Curl_conn_ev_update_info(data, data->conn);
+ /* Now that the complete filter chain is connected, let all filters
+ * persist information at the connection. E.g. cf-socket sets the
+ * socket and ip related information. */
+ cf_cntrl_update_info(data, data->conn);
conn_report_connect_stats(data, data->conn);
data->conn->keepalive = Curl_now();
}
@@ -501,6 +517,21 @@ bool Curl_conn_data_pending(struct Curl_easy *data, int sockindex)
return FALSE;
}
+bool Curl_conn_cf_needs_flush(struct Curl_cfilter *cf,
+ struct Curl_easy *data)
+{
+ CURLcode result;
+ int pending = FALSE;
+ result = cf? cf->cft->query(cf, data, CF_QUERY_NEED_FLUSH,
+ &pending, NULL) : CURLE_UNKNOWN_OPTION;
+ return (result || pending == FALSE)? FALSE : TRUE;
+}
+
+bool Curl_conn_needs_flush(struct Curl_easy *data, int sockindex)
+{
+ return Curl_conn_cf_needs_flush(data->conn->cfilter[sockindex], data);
+}
+
void Curl_conn_cf_adjust_pollset(struct Curl_cfilter *cf,
struct Curl_easy *data,
struct easy_pollset *ps)
@@ -627,6 +658,15 @@ curl_socket_t Curl_conn_cf_get_socket(struct Curl_cfilter *cf,
return CURL_SOCKET_BAD;
}
+CURLcode Curl_conn_cf_get_ip_info(struct Curl_cfilter *cf,
+ struct Curl_easy *data,
+ int *is_ipv6, struct ip_quadruple *ipquad)
+{
+ if(cf)
+ return cf->cft->query(cf, data, CF_QUERY_IP_INFO, is_ipv6, ipquad);
+ return CURLE_UNKNOWN_OPTION;
+}
+
curl_socket_t Curl_conn_get_socket(struct Curl_easy *data, int sockindex)
{
struct Curl_cfilter *cf;
@@ -693,6 +733,13 @@ CURLcode Curl_conn_ev_data_idle(struct Curl_easy *data)
CF_CTRL_DATA_IDLE, 0, NULL);
}
+
+CURLcode Curl_conn_flush(struct Curl_easy *data, int sockindex)
+{
+ return Curl_conn_cf_cntrl(data->conn->cfilter[sockindex], data, FALSE,
+ CF_CTRL_FLUSH, 0, NULL);
+}
+
/**
* Notify connection filters that the transfer represented by `data`
* is done with sending data (e.g. has uploaded everything).
@@ -717,8 +764,8 @@ CURLcode Curl_conn_ev_data_pause(struct Curl_easy *data, bool do_pause)
CF_CTRL_DATA_PAUSE, do_pause, NULL);
}
-void Curl_conn_ev_update_info(struct Curl_easy *data,
- struct connectdata *conn)
+static void cf_cntrl_update_info(struct Curl_easy *data,
+ struct connectdata *conn)
{
cf_cntrl_all(conn, data, TRUE, CF_CTRL_CONN_INFO_UPDATE, 0, NULL);
}
@@ -811,9 +858,10 @@ CURLcode Curl_conn_recv(struct Curl_easy *data, int sockindex,
}
CURLcode Curl_conn_send(struct Curl_easy *data, int sockindex,
- const void *buf, size_t blen,
+ const void *buf, size_t blen, bool eos,
size_t *pnwritten)
{
+ size_t write_len = blen;
ssize_t nwritten;
CURLcode result = CURLE_OK;
struct connectdata *conn;
@@ -831,11 +879,14 @@ CURLcode Curl_conn_send(struct Curl_easy *data, int sockindex,
if(p) {
size_t altsize = (size_t)strtoul(p, NULL, 10);
if(altsize)
- blen = CURLMIN(blen, altsize);
+ write_len = CURLMIN(write_len, altsize);
}
}
#endif
- nwritten = conn->send[sockindex](data, sockindex, buf, blen, &result);
+ if(write_len != blen)
+ eos = FALSE;
+ nwritten = conn->send[sockindex](data, sockindex, buf, write_len, eos,
+ &result);
DEBUGASSERT((nwritten >= 0) || result);
*pnwritten = (nwritten < 0)? 0 : (size_t)nwritten;
return result;