From 1ac4d7e042876d01b8084ec4c751f50b1a0d1ece Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 18 Jan 2021 11:59:14 +0100 Subject: progress: switch to Curl_easy * inputs --- lib/asyn-ares.c | 2 +- lib/file.c | 8 ++++---- lib/ftp.c | 2 +- lib/http.c | 2 +- lib/http_proxy.c | 4 ++-- lib/multi.c | 4 ++-- lib/pingpong.c | 2 +- lib/progress.c | 17 +++++++---------- lib/progress.h | 4 ++-- lib/rtsp.c | 2 +- lib/telnet.c | 2 +- lib/tftp.c | 4 ++-- lib/transfer.c | 4 ++-- lib/vssh/libssh2.c | 2 +- 14 files changed, 28 insertions(+), 31 deletions(-) diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index c8e8e14ea..c17cd265b 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -463,7 +463,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, if(result || conn->async.done) break; - if(Curl_pgrsUpdate(conn)) + if(Curl_pgrsUpdate(data)) result = CURLE_ABORTED_BY_CALLBACK; else { struct curltime now2 = Curl_now(); diff --git a/lib/file.c b/lib/file.c index 5156c7add..509e4836f 100644 --- a/lib/file.c +++ b/lib/file.c @@ -338,12 +338,12 @@ static CURLcode file_upload(struct Curl_easy *data) Curl_pgrsSetUploadCounter(data, bytecount); - if(Curl_pgrsUpdate(data->conn)) + if(Curl_pgrsUpdate(data)) result = CURLE_ABORTED_BY_CALLBACK; else result = Curl_speedcheck(data, Curl_now()); } - if(!result && Curl_pgrsUpdate(data->conn)) + if(!result && Curl_pgrsUpdate(data)) result = CURLE_ABORTED_BY_CALLBACK; close(fd); @@ -527,12 +527,12 @@ static CURLcode file_do(struct Curl_easy *data, bool *done) Curl_pgrsSetDownloadCounter(data, bytecount); - if(Curl_pgrsUpdate(conn)) + if(Curl_pgrsUpdate(data)) result = CURLE_ABORTED_BY_CALLBACK; else result = Curl_speedcheck(data, Curl_now()); } - if(Curl_pgrsUpdate(conn)) + if(Curl_pgrsUpdate(data)) result = CURLE_ABORTED_BY_CALLBACK; return result; diff --git a/lib/ftp.c b/lib/ftp.c index bb44bcdb2..3c1aab13c 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -678,7 +678,7 @@ CURLcode Curl_GetFTPResponse(struct Curl_easy *data, return CURLE_RECV_ERROR; case 0: /* timeout */ - if(Curl_pgrsUpdate(conn)) + if(Curl_pgrsUpdate(data)) return CURLE_ABORTED_BY_CALLBACK; continue; /* just continue in our loop for the timeout duration */ diff --git a/lib/http.c b/lib/http.c index 0d1d0d568..1555ab3ee 100644 --- a/lib/http.c +++ b/lib/http.c @@ -3184,7 +3184,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) /* if a request-body has been sent off, we make sure this progress is noted properly */ Curl_pgrsSetUploadCounter(data, data->req.writebytecount); - if(Curl_pgrsUpdate(conn)) + if(Curl_pgrsUpdate(data)) result = CURLE_ABORTED_BY_CALLBACK; if(!http->postsize) { diff --git a/lib/http_proxy.c b/lib/http_proxy.c index 8163c9694..82939fbdb 100644 --- a/lib/http_proxy.c +++ b/lib/http_proxy.c @@ -347,7 +347,7 @@ static CURLcode CONNECT(struct connectdata *conn, /* socket buffer drained, return */ return CURLE_OK; - if(Curl_pgrsUpdate(conn)) + if(Curl_pgrsUpdate(data)) return CURLE_ABORTED_BY_CALLBACK; if(result) { @@ -560,7 +560,7 @@ static CURLcode CONNECT(struct connectdata *conn, Curl_dyn_reset(&s->rcvbuf); } /* while there's buffer left and loop is requested */ - if(Curl_pgrsUpdate(conn)) + if(Curl_pgrsUpdate(data)) return CURLE_ABORTED_BY_CALLBACK; if(error) diff --git a/lib/multi.c b/lib/multi.c index 8d6d2cee1..fc68cd145 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -2069,7 +2069,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, case CURLM_STATE_TOOFAST: /* limit-rate exceeded in either direction */ DEBUGASSERT(data->conn); /* if both rates are within spec, resume transfer */ - if(Curl_pgrsUpdate(data->conn)) + if(Curl_pgrsUpdate(data)) result = CURLE_ABORTED_BY_CALLBACK; else result = Curl_speedcheck(data, *nowp); @@ -2352,7 +2352,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, rc = CURLM_CALL_MULTI_PERFORM; } /* if there's still a connection to use, call the progress function */ - else if(data->conn && Curl_pgrsUpdate(data->conn)) { + else if(data->conn && Curl_pgrsUpdate(data)) { /* aborted due to progress callback return code must close the connection */ result = CURLE_ABORTED_BY_CALLBACK; diff --git a/lib/pingpong.c b/lib/pingpong.c index 8ff394866..708f52d0f 100644 --- a/lib/pingpong.c +++ b/lib/pingpong.c @@ -117,7 +117,7 @@ CURLcode Curl_pp_statemach(struct Curl_easy *data, if(block) { /* if we didn't wait, we don't have to spend time on this now */ - if(Curl_pgrsUpdate(conn)) + if(Curl_pgrsUpdate(data)) result = CURLE_ABORTED_BY_CALLBACK; else result = Curl_speedcheck(data, Curl_now()); diff --git a/lib/progress.c b/lib/progress.c index 658d05ab8..ee383be4f 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2020, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2021, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -142,7 +142,7 @@ int Curl_pgrsDone(struct connectdata *conn) int rc; struct Curl_easy *data = conn->data; data->progress.lastshow = 0; - rc = Curl_pgrsUpdate(conn); /* the final (forced) update */ + rc = Curl_pgrsUpdate(data); /* the final (forced) update */ if(rc) return rc; @@ -371,11 +371,10 @@ void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size) } /* returns TRUE if it's time to show the progress meter */ -static bool progress_calc(struct connectdata *conn, struct curltime now) +static bool progress_calc(struct Curl_easy *data, struct curltime now) { curl_off_t timespent; curl_off_t timespent_ms; /* milliseconds */ - struct Curl_easy *data = conn->data; curl_off_t dl = data->progress.downloaded; curl_off_t ul = data->progress.uploaded; bool timetoshow = FALSE; @@ -465,9 +464,8 @@ static bool progress_calc(struct connectdata *conn, struct curltime now) } #ifndef CURL_DISABLE_PROGRESS_METER -static void progress_meter(struct connectdata *conn) +static void progress_meter(struct Curl_easy *data) { - struct Curl_easy *data = conn->data; char max5[6][10]; curl_off_t dlpercen = 0; curl_off_t ulpercen = 0; @@ -581,11 +579,10 @@ static void progress_meter(struct connectdata *conn) * Curl_pgrsUpdate() returns 0 for success or the value returned by the * progress callback! */ -int Curl_pgrsUpdate(struct connectdata *conn) +int Curl_pgrsUpdate(struct Curl_easy *data) { - struct Curl_easy *data = conn->data; struct curltime now = Curl_now(); /* what time is it */ - bool showprogress = progress_calc(conn, now); + bool showprogress = progress_calc(data, now); if(!(data->progress.flags & PGRS_HIDE)) { if(data->set.fxferinfo) { int result; @@ -621,7 +618,7 @@ int Curl_pgrsUpdate(struct connectdata *conn) } if(showprogress) - progress_meter(conn); + progress_meter(data); } return 0; diff --git a/lib/progress.h b/lib/progress.h index 74680099f..e512bcd61 100644 --- a/lib/progress.h +++ b/lib/progress.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2020, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2021, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -47,7 +47,7 @@ void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size); void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size); void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size); void Curl_ratelimit(struct Curl_easy *data, struct curltime now); -int Curl_pgrsUpdate(struct connectdata *); +int Curl_pgrsUpdate(struct Curl_easy *data); void Curl_pgrsResetTransferSizes(struct Curl_easy *data); struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer); timediff_t Curl_pgrsLimitWaitTime(curl_off_t cursize, diff --git a/lib/rtsp.c b/lib/rtsp.c index 46d0090e2..e40832513 100644 --- a/lib/rtsp.c +++ b/lib/rtsp.c @@ -590,7 +590,7 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done) /* if a request-body has been sent off, we make sure this progress is noted properly */ Curl_pgrsSetUploadCounter(data, data->req.writebytecount); - if(Curl_pgrsUpdate(conn)) + if(Curl_pgrsUpdate(data)) result = CURLE_ABORTED_BY_CALLBACK; } diff --git a/lib/telnet.c b/lib/telnet.c index ef99920b1..f82c22979 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -1575,7 +1575,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) } } - if(Curl_pgrsUpdate(conn)) { + if(Curl_pgrsUpdate(data)) { result = CURLE_ABORTED_BY_CALLBACK; break; } diff --git a/lib/tftp.c b/lib/tftp.c index c6af20e59..b18a0cc98 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -1201,7 +1201,7 @@ static CURLcode tftp_receive_packet(struct Curl_easy *data) } /* Update the progress meter */ - if(Curl_pgrsUpdate(conn)) { + if(Curl_pgrsUpdate(data)) { tftp_state_machine(state, TFTP_EVENT_ERROR); return CURLE_ABORTED_BY_CALLBACK; } @@ -1323,7 +1323,7 @@ static CURLcode tftp_doing(struct Curl_easy *data, bool *dophase_done) /* The multi code doesn't have this logic for the DOING state so we provide it for TFTP since it may do the entire transfer in this state. */ - if(Curl_pgrsUpdate(data->conn)) + if(Curl_pgrsUpdate(data)) result = CURLE_ABORTED_BY_CALLBACK; else result = Curl_speedcheck(data, Curl_now()); diff --git a/lib/transfer.c b/lib/transfer.c index 0a65c99b5..59b351519 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -1259,7 +1259,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, } } - if(Curl_pgrsUpdate(conn)) + if(Curl_pgrsUpdate(data)) result = CURLE_ABORTED_BY_CALLBACK; else result = Curl_speedcheck(data, k->now); @@ -1318,7 +1318,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, failf(data, "transfer closed with outstanding read data remaining"); return CURLE_PARTIAL_FILE; } - if(Curl_pgrsUpdate(conn)) + if(Curl_pgrsUpdate(data)) return CURLE_ABORTED_BY_CALLBACK; } diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index fb7b50335..cc0c188ad 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -2949,7 +2949,7 @@ static CURLcode ssh_block_statemach(struct Curl_easy *data, if(result) break; - if(Curl_pgrsUpdate(conn)) + if(Curl_pgrsUpdate(data)) return CURLE_ABORTED_BY_CALLBACK; result = Curl_speedcheck(data, now); -- cgit v1.2.1