mirror of
https://github.com/moparisthebest/curl
synced 2025-03-11 07:39:50 -04:00
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)
This commit is contained in:
parent
72c7c1d64e
commit
6cd084a3b5
@ -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;
|
struct SessionHandle *data = conn->data;
|
||||||
data->progress.lastshow=0;
|
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) &&
|
if(!(data->progress.flags & PGRS_HIDE) &&
|
||||||
!data->progress.callback)
|
!data->progress.callback)
|
||||||
@ -144,6 +147,7 @@ void Curl_pgrsDone(struct connectdata *conn)
|
|||||||
fprintf(data->set.err, "\n");
|
fprintf(data->set.err, "\n");
|
||||||
|
|
||||||
data->progress.speeder_c = 0; /* reset the progress meter display */
|
data->progress.speeder_c = 0; /* reset the progress meter display */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset all times except redirect, and reset the known transfer sizes */
|
/* 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;
|
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)
|
int Curl_pgrsUpdate(struct connectdata *conn)
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
|
@ -39,7 +39,7 @@ typedef enum {
|
|||||||
TIMER_LAST /* must be last */
|
TIMER_LAST /* must be last */
|
||||||
} timerid;
|
} timerid;
|
||||||
|
|
||||||
void Curl_pgrsDone(struct connectdata *);
|
int Curl_pgrsDone(struct connectdata *);
|
||||||
void Curl_pgrsStartNow(struct SessionHandle *data);
|
void Curl_pgrsStartNow(struct SessionHandle *data);
|
||||||
void Curl_pgrsSetDownloadSize(struct SessionHandle *data, curl_off_t size);
|
void Curl_pgrsSetDownloadSize(struct SessionHandle *data, curl_off_t size);
|
||||||
void Curl_pgrsSetUploadSize(struct SessionHandle *data, curl_off_t size);
|
void Curl_pgrsSetUploadSize(struct SessionHandle *data, curl_off_t size);
|
||||||
|
@ -2820,7 +2820,8 @@ static CURLcode ssh_done(struct connectdata *conn, CURLcode status)
|
|||||||
|
|
||||||
if(sftp_scp)
|
if(sftp_scp)
|
||||||
Curl_safefree(sftp_scp->path);
|
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 */
|
conn->data->req.keepon = 0; /* clear all bits */
|
||||||
return result;
|
return result;
|
||||||
|
@ -1036,7 +1036,8 @@ static CURLcode tftp_done(struct connectdata *conn, CURLcode status,
|
|||||||
(void)status; /* unused */
|
(void)status; /* unused */
|
||||||
(void)premature; /* not used */
|
(void)premature; /* not used */
|
||||||
|
|
||||||
Curl_pgrsDone(conn);
|
if(Curl_pgrsDone(conn))
|
||||||
|
return CURLE_ABORTED_BY_CALLBACK;
|
||||||
|
|
||||||
/* If we have encountered an error */
|
/* If we have encountered an error */
|
||||||
code = tftp_translate_code(state->error);
|
code = tftp_translate_code(state->error);
|
||||||
|
@ -5379,7 +5379,8 @@ CURLcode Curl_done(struct connectdata **connp,
|
|||||||
else
|
else
|
||||||
result = CURLE_OK;
|
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
|
/* if the transfer was completed in a paused state there can be buffered
|
||||||
data left to write and then kill */
|
data left to write and then kill */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user