diff options
author | dartraiden <wowemuh@gmail.com> | 2023-07-20 15:51:36 +0300 |
---|---|---|
committer | dartraiden <wowemuh@gmail.com> | 2023-07-20 16:02:00 +0300 |
commit | 1bec902c5a0b0161158aff935761dcb5754697d4 (patch) | |
tree | d97807c76c8a32b1dc9653655a34c8480d17fedb /libs/libcurl/src/bufq.c | |
parent | f7e76bcda435d7ca6f6c8f9d78ceba5ad2066d16 (diff) |
libcurl: update to 8.2.0
Diffstat (limited to 'libs/libcurl/src/bufq.c')
-rw-r--r-- | libs/libcurl/src/bufq.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/libs/libcurl/src/bufq.c b/libs/libcurl/src/bufq.c index de86b7136e..d851e63400 100644 --- a/libs/libcurl/src/bufq.c +++ b/libs/libcurl/src/bufq.c @@ -418,7 +418,8 @@ ssize_t Curl_bufq_write(struct bufq *q, break;
}
n = chunk_append(tail, buf, len);
- DEBUGASSERT(n);
+ if(!n)
+ break;
nwritten += n;
buf += n;
len -= n;
@@ -528,6 +529,14 @@ ssize_t Curl_bufq_pass(struct bufq *q, Curl_bufq_writer *writer, }
break;
}
+ if(!chunk_written) {
+ if(!nwritten) {
+ /* treat as blocked */
+ *err = CURLE_AGAIN;
+ nwritten = -1;
+ }
+ break;
+ }
Curl_bufq_skip(q, (size_t)chunk_written);
nwritten += chunk_written;
}
@@ -551,7 +560,8 @@ ssize_t Curl_bufq_write_pass(struct bufq *q, /* real error, fail */
return -1;
}
- /* would block */
+ /* would block, bufq is full, give up */
+ break;
}
}
@@ -562,16 +572,25 @@ ssize_t Curl_bufq_write_pass(struct bufq *q, /* real error, fail */
return -1;
}
- /* no room in bufq, bail out */
- goto out;
+ /* no room in bufq */
+ break;
}
+ /* edge case of writer returning 0 (and len is >0)
+ * break or we might enter an infinite loop here */
+ if(n == 0)
+ break;
+
/* Maybe only part of `data` has been added, continue to loop */
buf += (size_t)n;
len -= (size_t)n;
nwritten += (size_t)n;
}
-out:
+ if(!nwritten && len) {
+ *err = CURLE_AGAIN;
+ return -1;
+ }
+ *err = CURLE_OK;
return nwritten;
}
|