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.html

Reply via email to