Commit 6cd084a3 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

Curl_pgrsDone: return int and acknowledge return code

Since Curl_pgrsDone() itself calls Curl_pgrsUpdate() which may return an
abort instruction or similar we need to return that info back and
subsequently properly handle return codes from Curl_pgrsDone() where
used.

(Spotted by a Coverity scan)
parent 72c7c1d6
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -131,11 +131,14 @@ static char *max5data(curl_off_t bytes, char *max5)

*/

void Curl_pgrsDone(struct connectdata *conn)
int Curl_pgrsDone(struct connectdata *conn)
{
  int rc;
  struct SessionHandle *data = conn->data;
  data->progress.lastshow=0;
  Curl_pgrsUpdate(conn); /* the final (forced) update */
  rc = Curl_pgrsUpdate(conn); /* the final (forced) update */
  if(rc)
    return rc;

  if(!(data->progress.flags & PGRS_HIDE) &&
     !data->progress.callback)
@@ -144,6 +147,7 @@ void Curl_pgrsDone(struct connectdata *conn)
    fprintf(data->set.err, "\n");

  data->progress.speeder_c = 0; /* reset the progress meter display */
  return 0;
}

/* reset all times except redirect, and reset the known transfer sizes */
@@ -241,6 +245,10 @@ void Curl_pgrsSetUploadSize(struct SessionHandle *data, curl_off_t size)
    data->progress.flags &= ~PGRS_UL_SIZE_KNOWN;
}

/*
 * Curl_pgrsUpdate() returns 0 for success or the value returned by the
 * progress callback!
 */
int Curl_pgrsUpdate(struct connectdata *conn)
{
  struct timeval now;
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ typedef enum {
  TIMER_LAST /* must be last */
} timerid;

void Curl_pgrsDone(struct connectdata *);
int Curl_pgrsDone(struct connectdata *);
void Curl_pgrsStartNow(struct SessionHandle *data);
void Curl_pgrsSetDownloadSize(struct SessionHandle *data, curl_off_t size);
void Curl_pgrsSetUploadSize(struct SessionHandle *data, curl_off_t size);
+2 −1
Original line number Diff line number Diff line
@@ -2820,7 +2820,8 @@ static CURLcode ssh_done(struct connectdata *conn, CURLcode status)

  if(sftp_scp)
    Curl_safefree(sftp_scp->path);
  Curl_pgrsDone(conn);
  if(Curl_pgrsDone(conn))
    return CURLE_ABORTED_BY_CALLBACK;

  conn->data->req.keepon = 0; /* clear all bits */
  return result;
+2 −1
Original line number Diff line number Diff line
@@ -1036,7 +1036,8 @@ static CURLcode tftp_done(struct connectdata *conn, CURLcode status,
  (void)status; /* unused */
  (void)premature; /* not used */

  Curl_pgrsDone(conn);
  if(Curl_pgrsDone(conn))
    return CURLE_ABORTED_BY_CALLBACK;

  /* If we have encountered an error */
  code = tftp_translate_code(state->error);
+2 −1
Original line number Diff line number Diff line
@@ -5379,7 +5379,8 @@ CURLcode Curl_done(struct connectdata **connp,
  else
    result = CURLE_OK;

  Curl_pgrsDone(conn); /* done with the operation */
  if(Curl_pgrsDone(conn) && !result)
    result = CURLE_ABORTED_BY_CALLBACK;

  /* if the transfer was completed in a paused state there can be buffered
     data left to write and then kill */