summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/sendf.c
diff options
context:
space:
mode:
authordartraiden <wowemuh@gmail.com>2023-09-16 22:53:10 +0300
committerdartraiden <wowemuh@gmail.com>2023-09-16 22:53:10 +0300
commit47346b568cae68439c3d39f06f8c4ab14911475d (patch)
tree617c91959e8c606a315a1aaaf13a38f5b7333e9a /libs/libcurl/src/sendf.c
parentcb1787afbb67184321f206f13f836b63cd06740a (diff)
libcurl: update to 8.3.0
Diffstat (limited to 'libs/libcurl/src/sendf.c')
-rw-r--r--libs/libcurl/src/sendf.c81
1 files changed, 48 insertions, 33 deletions
diff --git a/libs/libcurl/src/sendf.c b/libs/libcurl/src/sendf.c
index 568493d56b..da82a92a19 100644
--- a/libs/libcurl/src/sendf.c
+++ b/libs/libcurl/src/sendf.c
@@ -139,27 +139,27 @@ static size_t convert_lineends(struct Curl_easy *data,
#endif /* CURL_DO_LINEEND_CONV && !CURL_DISABLE_FTP */
/*
- * Curl_write() is an internal write function that sends data to the
- * server. Works with plain sockets, SCP, SSL or kerberos.
+ * Curl_nwrite() is an internal write function that sends data to the
+ * server. Works with a socket index for the connection.
*
- * If the write would block (CURLE_AGAIN), we return CURLE_OK and
- * (*written == 0). Otherwise we return regular CURLcode value.
+ * If the write would block (CURLE_AGAIN), it returns CURLE_OK and
+ * (*nwritten == 0). Otherwise we return regular CURLcode value.
*/
-CURLcode Curl_write(struct Curl_easy *data,
- curl_socket_t sockfd,
- const void *mem,
- size_t len,
- ssize_t *written)
+CURLcode Curl_nwrite(struct Curl_easy *data,
+ int sockindex,
+ const void *buf,
+ size_t blen,
+ ssize_t *pnwritten)
{
- ssize_t bytes_written;
+ ssize_t nwritten;
CURLcode result = CURLE_OK;
struct connectdata *conn;
- int num;
+
+ DEBUGASSERT(sockindex >= 0 && sockindex < 2);
+ DEBUGASSERT(pnwritten);
DEBUGASSERT(data);
DEBUGASSERT(data->conn);
conn = data->conn;
- num = (sockfd != CURL_SOCKET_BAD && sockfd == conn->sock[SECONDARYSOCKET]);
-
#ifdef CURLDEBUG
{
/* Allow debug builds to override this logic to force short sends
@@ -168,31 +168,47 @@ CURLcode Curl_write(struct Curl_easy *data,
if(p) {
size_t altsize = (size_t)strtoul(p, NULL, 10);
if(altsize)
- len = CURLMIN(len, altsize);
+ blen = CURLMIN(blen, altsize);
}
}
#endif
- bytes_written = conn->send[num](data, num, mem, len, &result);
-
- *written = bytes_written;
- if(bytes_written >= 0)
- /* we completely ignore the curlcode value when subzero is not returned */
- return CURLE_OK;
+ nwritten = conn->send[sockindex](data, sockindex, buf, blen, &result);
+ if(result == CURLE_AGAIN) {
+ nwritten = 0;
+ result = CURLE_OK;
+ }
+ else if(result) {
+ nwritten = -1; /* make sure */
+ }
+ else {
+ DEBUGASSERT(nwritten >= 0);
+ }
- /* handle CURLE_AGAIN or a send failure */
- switch(result) {
- case CURLE_AGAIN:
- *written = 0;
- return CURLE_OK;
+ *pnwritten = nwritten;
+ return result;
+}
- case CURLE_OK:
- /* general send failure */
- return CURLE_SEND_ERROR;
+/*
+ * Curl_write() is an internal write function that sends data to the
+ * server. Works with plain sockets, SCP, SSL or kerberos.
+ *
+ * If the write would block (CURLE_AGAIN), we return CURLE_OK and
+ * (*written == 0). Otherwise we return regular CURLcode value.
+ */
+CURLcode Curl_write(struct Curl_easy *data,
+ curl_socket_t sockfd,
+ const void *mem,
+ size_t len,
+ ssize_t *written)
+{
+ struct connectdata *conn;
+ int num;
- default:
- /* we got a specific curlcode, forward it */
- return result;
- }
+ DEBUGASSERT(data);
+ DEBUGASSERT(data->conn);
+ conn = data->conn;
+ num = (sockfd != CURL_SOCKET_BAD && sockfd == conn->sock[SECONDARYSOCKET]);
+ return Curl_nwrite(data, num, mem, len, written);
}
static CURLcode pausewrite(struct Curl_easy *data,
@@ -421,4 +437,3 @@ CURLcode Curl_read(struct Curl_easy *data, /* transfer */
out:
return result;
}
-