Skip to content

CURL_READFUNC_ABORT is lost if returned in a middle of transfer #4813

@MrdUkk

Description

@MrdUkk

I did this

I'm uploading multipart form data (large stream) to server.
    I'm doing it by using curl_easy_perform() in thread1 with specified CURLOPT_READFUNCTION
   CURLOPT_READDATA, CURLOPT_WRITEDATA, CURLOPT_NOPROGRESS =0.

in a middle of transfer want to cancel transfer. so i return in my callback function to CURL specified
CURL_READFUNC_ABORT value.

I expected the following

expect to see immediately aborted transfer but libcurl REPEATEDLY call again and again my callback function and doesn't stop!

curl/libcurl version

7.68.0

operating system

VS2015 Windows 8.1.

after debugging i find out some strange behaviour in mime.c function
readback_part() calling sz = read_part_content(part, buffer, bufsize);
we are returning in sz CURL_READFUNC_ABORT value , stepping next switch

  switch(sz) {
  case 0:
    mimesetstate(&part->state, MIMESTATE_END, NULL);
    /* Try sparing open file descriptors. */
    if(part->kind == MIMEKIND_FILE && part->fp) {
      fclose(part->fp);
      part->fp = NULL;
    }
    /* FALLTHROUGH */
  case CURL_READFUNC_ABORT:
  case CURL_READFUNC_PAUSE:
  case READ_ERROR:
    return cursize? cursize: sz;
  }

here i see random non zero 'cursize' values (is it bytes transfered already before we abort?)
and cursize is not zero it will don't return (losing) proper CURL_READFUNC_ABORT to upper levels of callstack.
it's sounds something simular to old 2011 bug . (see git repo commit 840eff4).
transfer isn't stopped and hung in curl_easy_perform()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions