multi: add xfer_buf to multi handle

- can be borrowed by transfer during recv-write operation
- needs to be released before borrowing again
- adjustis size to `data->set.buffer_size`
- used in transfer.c readwrite_data()

Closes #12805
This commit is contained in:
Stefan Eissing 2024-01-26 12:05:08 +01:00 committed by Daniel Stenberg
parent c54d0ff6b3
commit 476adfeac0
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
10 changed files with 113 additions and 25 deletions

View file

@ -466,15 +466,18 @@ static CURLcode readwrite_data(struct Curl_easy *data,
{
struct connectdata *conn = data->conn;
CURLcode result = CURLE_OK;
char *buf;
size_t blen;
char *buf, *xfer_buf;
size_t blen, xfer_blen;
int maxloops = 10;
curl_off_t total_received = 0;
bool is_multiplex = FALSE;
DEBUGASSERT(data->state.buffer);
*done = FALSE;
result = Curl_multi_xfer_buf_borrow(data, &xfer_buf, &xfer_blen);
if(result)
goto out;
/* This is where we loop until we have read everything there is to
read or we get a CURLE_AGAIN */
do {
@ -489,8 +492,8 @@ static CURLcode readwrite_data(struct Curl_easy *data,
is_multiplex = Curl_conn_is_multiplex(conn, FIRSTSOCKET);
}
buf = data->state.buffer;
bytestoread = data->set.buffer_size;
buf = xfer_buf;
bytestoread = xfer_blen;
/* Observe any imposed speed limit */
if(bytestoread && data->set.max_recv_speed) {
@ -564,6 +567,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
}
out:
Curl_multi_xfer_buf_release(data, xfer_buf);
if(result)
DEBUGF(infof(data, "readwrite_data() -> %d", result));
return result;