[pacman-dev] [PATCH] Replace CURLOPT_PROGRESSFUNCTION with CURLOPT_XFERINFOFUNCTION
From: Ivy Foster <ivy.foster@gmail.com> Curl 7.32.0 added CURLOPT_XFERINFOFUNCTION, which deprecates CURLOPT_PROGRESSFUNCTION and means less casting doubles to size_ts for alpm. This change has no user-facing nor frontend-facing effects. Signed-off-by: Ivy Foster <ivy.foster@gmail.com> --- lib/libalpm/dload.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index f4e6a27..dc57c92 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -90,8 +90,8 @@ static void inthandler(int UNUSED signum) dload_interrupted = ABORT_SIGINT; } -static int dload_progress_cb(void *file, double dltotal, double dlnow, - double UNUSED ultotal, double UNUSED ulnow) +static int dload_progress_cb(void *file, curl_off_t dltotal, curl_off_t dlnow, + curl_off_t UNUSED ultotal, curl_off_t UNUSED ulnow) { struct dload_payload *payload = (struct dload_payload *)file; off_t current_size, total_size; @@ -106,7 +106,7 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow, return 1; } - current_size = payload->initial_size + (off_t)dlnow; + current_size = payload->initial_size + dlnow; /* is our filesize still under any set limit? */ if(payload->max_size && current_size > payload->max_size) { @@ -119,9 +119,9 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow, return 0; } - total_size = payload->initial_size + (off_t)dltotal; + total_size = payload->initial_size + dltotal; - if(DOUBLE_EQ(dltotal, 0.0) || payload->prevprogress == total_size) { + if(dltotal == 0 || payload->prevprogress == total_size) { return 0; } @@ -134,7 +134,7 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow, * x {x>0}, x: download complete * x {x>0, x<y}, y {y > 0}: download progress, expected total is known */ if(current_size == total_size) { - payload->handle->dlcb(payload->remote_name, (off_t)dlnow, (off_t)dltotal); + payload->handle->dlcb(payload->remote_name, dlnow, dltotal); } else if(!payload->prevprogress) { payload->handle->dlcb(payload->remote_name, 0, -1); } else if(payload->prevprogress == current_size) { @@ -142,7 +142,7 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow, } else { /* do NOT include initial_size since it wasn't part of the package's * download_size (nor included in the total download size callback) */ - payload->handle->dlcb(payload->remote_name, (off_t)dlnow, (off_t)dltotal); + payload->handle->dlcb(payload->remote_name, dlnow, dltotal); } payload->prevprogress = current_size; @@ -303,8 +303,8 @@ static void curl_set_handle_opts(struct dload_payload *payload, curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, dload_progress_cb); - curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void *)payload); + curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, dload_progress_cb); + curl_easy_setopt(curl, CURLOPT_XFERINFODATA, (void *)payload); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L); curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, dload_parseheader_cb); -- 2.9.3
On Tue, Aug 30, 2016 at 02:54:31PM -0500, ivy.foster@gmail.com wrote:
From: Ivy Foster <ivy.foster@gmail.com>
Curl 7.32.0 added CURLOPT_XFERINFOFUNCTION, which deprecates CURLOPT_PROGRESSFUNCTION and means less casting doubles to size_ts for alpm. This change has no user-facing nor frontend-facing effects.
Making this change would require that you update configure.ac to bump the minimum version for libcurl (which is currently 7.19.4). FWIW 7.32.0 was released in August 2013.
Signed-off-by: Ivy Foster <ivy.foster@gmail.com> --- lib/libalpm/dload.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index f4e6a27..dc57c92 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -90,8 +90,8 @@ static void inthandler(int UNUSED signum) dload_interrupted = ABORT_SIGINT; }
-static int dload_progress_cb(void *file, double dltotal, double dlnow, - double UNUSED ultotal, double UNUSED ulnow) +static int dload_progress_cb(void *file, curl_off_t dltotal, curl_off_t dlnow, + curl_off_t UNUSED ultotal, curl_off_t UNUSED ulnow) { struct dload_payload *payload = (struct dload_payload *)file; off_t current_size, total_size; @@ -106,7 +106,7 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow, return 1; }
- current_size = payload->initial_size + (off_t)dlnow; + current_size = payload->initial_size + dlnow;
/* is our filesize still under any set limit? */ if(payload->max_size && current_size > payload->max_size) { @@ -119,9 +119,9 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow, return 0; }
- total_size = payload->initial_size + (off_t)dltotal; + total_size = payload->initial_size + dltotal;
- if(DOUBLE_EQ(dltotal, 0.0) || payload->prevprogress == total_size) { + if(dltotal == 0 || payload->prevprogress == total_size) { return 0; }
@@ -134,7 +134,7 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow, * x {x>0}, x: download complete * x {x>0, x<y}, y {y > 0}: download progress, expected total is known */ if(current_size == total_size) { - payload->handle->dlcb(payload->remote_name, (off_t)dlnow, (off_t)dltotal); + payload->handle->dlcb(payload->remote_name, dlnow, dltotal); } else if(!payload->prevprogress) { payload->handle->dlcb(payload->remote_name, 0, -1); } else if(payload->prevprogress == current_size) { @@ -142,7 +142,7 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow, } else { /* do NOT include initial_size since it wasn't part of the package's * download_size (nor included in the total download size callback) */ - payload->handle->dlcb(payload->remote_name, (off_t)dlnow, (off_t)dltotal); + payload->handle->dlcb(payload->remote_name, dlnow, dltotal); }
payload->prevprogress = current_size; @@ -303,8 +303,8 @@ static void curl_set_handle_opts(struct dload_payload *payload, curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, dload_progress_cb); - curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void *)payload); + curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, dload_progress_cb); + curl_easy_setopt(curl, CURLOPT_XFERINFODATA, (void *)payload); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L); curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, dload_parseheader_cb); -- 2.9.3
On Tue, Aug 30, 2016 at 02:54:31PM -0500, Dave Reisner <d@falconindy.com> wrote:
From: Ivy Foster <ivy.foster@gmail.com>
Curl 7.32.0 added CURLOPT_XFERINFOFUNCTION
Making this change would require that you update configure.ac to bump the minimum version for libcurl (which is currently 7.19.4). FWIW 7.32.0 was released in August 2013.
Ah, okay, that didn't even occur to me (clearly). Thanks for the feedback. This version of the patch includes the updated. configure.ac check. iff
From: Ivy Foster <ivy.foster@gmail.com> Curl 7.32.0 added CURLOPT_XFERINFOFUNCTION, which deprecates CURLOPT_PROGRESSFUNCTION and means less casting doubles to size_ts for alpm. This change has no user-facing nor frontend-facing effects. Signed-off-by: Ivy Foster <ivy.foster@gmail.com> --- configure.ac | 4 ++-- lib/libalpm/dload.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 51288e7..d4a1c9f 100644 --- a/configure.ac +++ b/configure.ac @@ -232,10 +232,10 @@ AM_CONDITIONAL(HAVE_LIBSSL, [test "$have_openssl" = "yes"]) # Check for libcurl have_libcurl=no if test "x$with_libcurl" != "xno"; then - PKG_CHECK_MODULES(LIBCURL, [libcurl >= 7.19.4], + PKG_CHECK_MODULES(LIBCURL, [libcurl >= 7.32.0], [AC_DEFINE(HAVE_LIBCURL, 1, [Define if libcurl is available]) have_libcurl=yes], have_libcurl=no) if test "x$have_libcurl" = xno -a "x$with_libcurl" = xyes; then - AC_MSG_ERROR([*** libcurl >= 7.19.4 is required for internal downloader support]) + AC_MSG_ERROR([*** libcurl >= 7.32.0 is required for internal downloader support]) fi fi AM_CONDITIONAL(HAVE_LIBCURL, [test "$have_libcurl" = "yes"]) diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index f4e6a27..dc57c92 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -90,8 +90,8 @@ static void inthandler(int UNUSED signum) dload_interrupted = ABORT_SIGINT; } -static int dload_progress_cb(void *file, double dltotal, double dlnow, - double UNUSED ultotal, double UNUSED ulnow) +static int dload_progress_cb(void *file, curl_off_t dltotal, curl_off_t dlnow, + curl_off_t UNUSED ultotal, curl_off_t UNUSED ulnow) { struct dload_payload *payload = (struct dload_payload *)file; off_t current_size, total_size; @@ -106,7 +106,7 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow, return 1; } - current_size = payload->initial_size + (off_t)dlnow; + current_size = payload->initial_size + dlnow; /* is our filesize still under any set limit? */ if(payload->max_size && current_size > payload->max_size) { @@ -119,9 +119,9 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow, return 0; } - total_size = payload->initial_size + (off_t)dltotal; + total_size = payload->initial_size + dltotal; - if(DOUBLE_EQ(dltotal, 0.0) || payload->prevprogress == total_size) { + if(dltotal == 0 || payload->prevprogress == total_size) { return 0; } @@ -134,7 +134,7 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow, * x {x>0}, x: download complete * x {x>0, x<y}, y {y > 0}: download progress, expected total is known */ if(current_size == total_size) { - payload->handle->dlcb(payload->remote_name, (off_t)dlnow, (off_t)dltotal); + payload->handle->dlcb(payload->remote_name, dlnow, dltotal); } else if(!payload->prevprogress) { payload->handle->dlcb(payload->remote_name, 0, -1); } else if(payload->prevprogress == current_size) { @@ -142,7 +142,7 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow, } else { /* do NOT include initial_size since it wasn't part of the package's * download_size (nor included in the total download size callback) */ - payload->handle->dlcb(payload->remote_name, (off_t)dlnow, (off_t)dltotal); + payload->handle->dlcb(payload->remote_name, dlnow, dltotal); } payload->prevprogress = current_size; @@ -303,8 +303,8 @@ static void curl_set_handle_opts(struct dload_payload *payload, curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, dload_progress_cb); - curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void *)payload); + curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, dload_progress_cb); + curl_easy_setopt(curl, CURLOPT_XFERINFODATA, (void *)payload); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L); curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, dload_parseheader_cb); -- 2.9.3
On 31/08/16 06:33, ivy.foster@gmail.com wrote:
From: Ivy Foster <ivy.foster@gmail.com>
Curl 7.32.0 added CURLOPT_XFERINFOFUNCTION, which deprecates CURLOPT_PROGRESSFUNCTION and means less casting doubles to size_ts for alpm. This change has no user-facing nor frontend-facing effects.
OK. I don't think pacman is used anywhere where curl older than August 2013 is an issue... Allan
On 2016-08-30 11:01 PM, Allan McRae wrote:
OK. I don't think pacman is used anywhere where curl older than August 2013 is an issue...
Allan
I guess I'm the exception that proves the rule -- I'm using pacman on QNX 6.6, which ships with libcurl 7.24.0 from Jan 2012. Alas, RTOS folks are notoriously conservative thanks to long certification processes. That said, I would still endorse this patch; it's no big deal for me to arrange to build an updated curl for our platform, now that I have pacman to manage its deployment. :) -Will
participants (4)
-
Allan McRae
-
Dave Reisner
-
ivy.foster@gmail.com
-
Will Miles