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

@ -94,4 +94,28 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
/* Return the value of the CURLMOPT_MAX_CONCURRENT_STREAMS option */
unsigned int Curl_multi_max_concurrent_streams(struct Curl_multi *multi);
/**
* Borrow the transfer buffer from the multi, suitable
* for the given transfer `data`. The buffer may only be used in one
* multi processing of the easy handle. It MUST be returned to the
* multi before it can be borrowed again.
* Pointers into the buffer remain only valid as long as it is borrowed.
*
* @param data the easy handle
* @param pbuf on return, the buffer to use or NULL on error
* @param pbuflen on return, the size of *pbuf or 0 on error
* @return CURLE_OK when buffer is available and is returned.
* CURLE_OUT_OF_MEMORy on failure to allocate the buffer,
* CURLE_FAILED_INIT if the easy handle is without multi.
* CURLE_AGAIN if the buffer is borrowed already.
*/
CURLcode Curl_multi_xfer_buf_borrow(struct Curl_easy *data,
char **pbuf, size_t *pbuflen);
/**
* Release the borrowed buffer. All references into the buffer become
* invalid after this.
* @param buf the buffer pointer borrowed for coding error checks.
*/
void Curl_multi_xfer_buf_release(struct Curl_easy *data, char *buf);
#endif /* HEADER_CURL_MULTIIF_H */