Buy commercial curl support from WolfSSL. We help you work
out your issues, debug your libcurl applications, use the API, port to new
platforms, add new features and more. With a team lead by the curl founder
himself.
Potential hang problem on paused upload transfer when it is marked for closing
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Dmitry Karpov via curl-library <curl-library_at_lists.haxx.se>
Date: Tue, 28 Nov 2023 19:47:23 +0000
Hi All,
I stepped on some strange problem when one of my paused uploading transfers didn't get completion event when it was marked for closing (conn->bits.close was set).
Debugging revealed a potential hanging issue in the readwrite_data() function in transfer.c:
static CURLcode readwrite_data(struct Curl_easy *data,
struct connectdata *conn,
struct SingleRequest *k,
int *didwhat, bool *done,
bool *comeback)
{
...
if(((k->keepon & (KEEP_RECV|KEEP_SEND)) == KEEP_SEND) &&
conn->bits.close) {
/* When we've read the entire thing and the close bit is set, the server
may now close the connection. If there's now any kind of sending going
on from our side, we need to stop that immediately. */
infof(data, "we are done reading and this is set to close, stop send");
k->keepon &= ~KEEP_SEND; /* no writing anymore either */
// !!! The uploading transfer may be paused here.
}
return CURLE_OK;
}
It looks like clearing just the KEEP_SEND in the "keepon" flags wasn't enough to unpause and finish the transfer.
I am wondering if the KEEP_SEND_PAUSE flag should be also cleared in this case?
Like:
if(((k->keepon & (KEEP_RECV|KEEP_SEND)) == KEEP_SEND) &&
conn->bits.close) {
...
k->keepon &= ~KEEP_SEND; /* no writing anymore either */
k->keepon &= ~KEEP_SEND_PAUSE; /* no pausing anymore either */
}
It worked out in my case, but maybe there are some other implications which I don't see with this solution.
Thanks,
Dmitry Karpov
Date: Tue, 28 Nov 2023 19:47:23 +0000
Hi All,
I stepped on some strange problem when one of my paused uploading transfers didn't get completion event when it was marked for closing (conn->bits.close was set).
Debugging revealed a potential hanging issue in the readwrite_data() function in transfer.c:
static CURLcode readwrite_data(struct Curl_easy *data,
struct connectdata *conn,
struct SingleRequest *k,
int *didwhat, bool *done,
bool *comeback)
{
...
if(((k->keepon & (KEEP_RECV|KEEP_SEND)) == KEEP_SEND) &&
conn->bits.close) {
/* When we've read the entire thing and the close bit is set, the server
may now close the connection. If there's now any kind of sending going
on from our side, we need to stop that immediately. */
infof(data, "we are done reading and this is set to close, stop send");
k->keepon &= ~KEEP_SEND; /* no writing anymore either */
// !!! The uploading transfer may be paused here.
}
return CURLE_OK;
}
It looks like clearing just the KEEP_SEND in the "keepon" flags wasn't enough to unpause and finish the transfer.
I am wondering if the KEEP_SEND_PAUSE flag should be also cleared in this case?
Like:
if(((k->keepon & (KEEP_RECV|KEEP_SEND)) == KEEP_SEND) &&
conn->bits.close) {
...
k->keepon &= ~KEEP_SEND; /* no writing anymore either */
k->keepon &= ~KEEP_SEND_PAUSE; /* no pausing anymore either */
}
It worked out in my case, but maybe there are some other implications which I don't see with this solution.
Thanks,
Dmitry Karpov
-- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2023-11-28