Skip to contentSkip to conversation

curl: remove compatibility code

PATCH In review Paolo Bonzini 2 participants 4 messages Nov 17, 2020 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 curl: remove compatibility code

cURL 7.16.0 was released in October 2006. Just remove code that is in all likelihood not being used anywhere.

---
 block/curl.c | 28 ----------------------------
 1 file changed, 28 deletions(-)
block/curl.c +0 -28
index 4f907c47be..b77bfe12e7 100644
@@ -37,26 +37,6 @@
 
 // #define DEBUG_VERBOSE
 
-#if LIBCURL_VERSION_NUM >= 0x071000
-/* The multi interface timer callback was introduced in 7.16.0 */
-#define NEED_CURL_TIMER_CALLBACK
-#define HAVE_SOCKET_ACTION
-#endif
-
-#ifndef HAVE_SOCKET_ACTION
-/* If curl_multi_socket_action isn't available, define it statically here in
- * terms of curl_multi_socket. Note that ev_bitmask will be ignored, which is
- * less efficient but still safe. */
-static CURLMcode __curl_multi_socket_action(CURLM *multi_handle,
-                                            curl_socket_t sockfd,
-                                            int ev_bitmask,
-                                            int *running_handles)
-{
-    return curl_multi_socket(multi_handle, sockfd, running_handles);
-}
-#define curl_multi_socket_action __curl_multi_socket_action
-#endif
-
 #define PROTOCOLS (CURLPROTO_HTTP | CURLPROTO_HTTPS | \
                    CURLPROTO_FTP | CURLPROTO_FTPS)
 
@@ -140,7 +120,6 @@ typedef struct BDRVCURLState {
 static void curl_clean_state(CURLState *s);
 static void curl_multi_do(void *arg);
 
-#ifdef NEED_CURL_TIMER_CALLBACK
 /* Called from curl_multi_do_locked, with s->mutex held.  */
 static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque)
 {
@@ -156,7 +135,6 @@ static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque)
     }
     return 0;
 }
-#endif
 
 /* Called from curl_multi_do_locked, with s->mutex held.  */
 static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
@@ -433,7 +411,6 @@ static void curl_multi_do(void *arg)
 
 static void curl_multi_timeout_do(void *arg)
 {
-#ifdef NEED_CURL_TIMER_CALLBACK
     BDRVCURLState *s = (BDRVCURLState *)arg;
     int running;
 
@@ -446,9 +423,6 @@ static void curl_multi_timeout_do(void *arg)
 
     curl_multi_check_completion(s);
     qemu_mutex_unlock(&s->mutex);
-#else
-    abort();
-#endif
 }
 
 /* Called with s->mutex held.  */
@@ -598,10 +572,8 @@ static void curl_attach_aio_context(BlockDriverState *bs,
     s->multi = curl_multi_init();
     s->aio_context = new_context;
     curl_multi_setopt(s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb);
-#ifdef NEED_CURL_TIMER_CALLBACK
     curl_multi_setopt(s->multi, CURLMOPT_TIMERDATA, s);
     curl_multi_setopt(s->multi, CURLMOPT_TIMERFUNCTION, curl_timer_cb);
-#endif
 }
 
 static QemuOptsList runtime_opts = {
Signature · 1 line
2.28.0
#1 lore raw
Quoted 2 lines · Paolo Bonzini

cURL 7.16.0 was released in October 2006. Just remove code that is in all likelihood not being used anywhere.

Rather than assuming that, we should be picking our minimum version and enforcing that in configure/meson.

Currently, we have a manual code compile check for curl_multi_setopt, after doing a pkg-config check with no min version.

We should set a min version in pkg-config and drop the compile check in configure.

Based on repology.org and our platform support matrix, RHEL-7 looks like the oldest curl that we need to care about, 7.29.0

Quoted 86 lines
---
 block/curl.c | 28 ----------------------------
 1 file changed, 28 deletions(-)
block/curl.c +0 -28
index 4f907c47be..b77bfe12e7 100644
@@ -37,26 +37,6 @@
 
 // #define DEBUG_VERBOSE
 
-#if LIBCURL_VERSION_NUM >= 0x071000
-/* The multi interface timer callback was introduced in 7.16.0 */
-#define NEED_CURL_TIMER_CALLBACK
-#define HAVE_SOCKET_ACTION
-#endif
-
-#ifndef HAVE_SOCKET_ACTION
-/* If curl_multi_socket_action isn't available, define it statically here in
- * terms of curl_multi_socket. Note that ev_bitmask will be ignored, which is
- * less efficient but still safe. */
-static CURLMcode __curl_multi_socket_action(CURLM *multi_handle,
-                                            curl_socket_t sockfd,
-                                            int ev_bitmask,
-                                            int *running_handles)
-{
-    return curl_multi_socket(multi_handle, sockfd, running_handles);
-}
-#define curl_multi_socket_action __curl_multi_socket_action
-#endif
-
 #define PROTOCOLS (CURLPROTO_HTTP | CURLPROTO_HTTPS | \
                    CURLPROTO_FTP | CURLPROTO_FTPS)
 
@@ -140,7 +120,6 @@ typedef struct BDRVCURLState {
 static void curl_clean_state(CURLState *s);
 static void curl_multi_do(void *arg);
 
-#ifdef NEED_CURL_TIMER_CALLBACK
 /* Called from curl_multi_do_locked, with s->mutex held.  */
 static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque)
 {
@@ -156,7 +135,6 @@ static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque)
     }
     return 0;
 }
-#endif
 
 /* Called from curl_multi_do_locked, with s->mutex held.  */
 static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
@@ -433,7 +411,6 @@ static void curl_multi_do(void *arg)
 
 static void curl_multi_timeout_do(void *arg)
 {
-#ifdef NEED_CURL_TIMER_CALLBACK
     BDRVCURLState *s = (BDRVCURLState *)arg;
     int running;
 
@@ -446,9 +423,6 @@ static void curl_multi_timeout_do(void *arg)
 
     curl_multi_check_completion(s);
     qemu_mutex_unlock(&s->mutex);
-#else
-    abort();
-#endif
 }
 
 /* Called with s->mutex held.  */
@@ -598,10 +572,8 @@ static void curl_attach_aio_context(BlockDriverState *bs,
     s->multi = curl_multi_init();
     s->aio_context = new_context;
     curl_multi_setopt(s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb);
-#ifdef NEED_CURL_TIMER_CALLBACK
     curl_multi_setopt(s->multi, CURLMOPT_TIMERDATA, s);
     curl_multi_setopt(s->multi, CURLMOPT_TIMERFUNCTION, curl_timer_cb);
-#endif
 }
 
 static QemuOptsList runtime_opts = {
Signature · 1 line
2.28.0

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#2 lore raw
Quoted 7 lines · Daniel P. Berrangé
Quoted 2 lines · Paolo Bonzini

cURL 7.16.0 was released in October 2006. Just remove code that is in all likelihood not being used anywhere.

Rather than assuming that, we should be picking our minimum version and enforcing that in configure/meson.

Quoted 8 lines

Currently, we have a manual code compile check for curl_multi_setopt, after doing a pkg-config check with no min version.

We should set a min version in pkg-config and drop the compile check in configure.

Based on repology.org and our platform support matrix, RHEL-7 looks like the oldest curl that we need to care about, 7.29.0

That is complicated a bit by the fact that curl is detected with both pkg-config and curl-config. That is probably unnecessary too, since we do not need any of the options that are exclusive to curl-config, such as --ca. If we can drop curl-config, moving the detection to meson is much easier.

Paolo

Quoted 90 lines
Quoted 86 lines
---
  block/curl.c | 28 ----------------------------
  1 file changed, 28 deletions(-)
block/curl.c +0 -28
index 4f907c47be..b77bfe12e7 100644
@@ -37,26 +37,6 @@
 
  // #define DEBUG_VERBOSE
 
-#if LIBCURL_VERSION_NUM >= 0x071000
-/* The multi interface timer callback was introduced in 7.16.0 */
-#define NEED_CURL_TIMER_CALLBACK
-#define HAVE_SOCKET_ACTION
-#endif
-
-#ifndef HAVE_SOCKET_ACTION
-/* If curl_multi_socket_action isn't available, define it statically here in
- * terms of curl_multi_socket. Note that ev_bitmask will be ignored, which is
- * less efficient but still safe. */
-static CURLMcode __curl_multi_socket_action(CURLM *multi_handle,
-                                            curl_socket_t sockfd,
-                                            int ev_bitmask,
-                                            int *running_handles)
-{
-    return curl_multi_socket(multi_handle, sockfd, running_handles);
-}
-#define curl_multi_socket_action __curl_multi_socket_action
-#endif
-
  #define PROTOCOLS (CURLPROTO_HTTP | CURLPROTO_HTTPS | \
                     CURLPROTO_FTP | CURLPROTO_FTPS)
 
@@ -140,7 +120,6 @@ typedef struct BDRVCURLState {
  static void curl_clean_state(CURLState *s);
  static void curl_multi_do(void *arg);
 
-#ifdef NEED_CURL_TIMER_CALLBACK
  /* Called from curl_multi_do_locked, with s->mutex held.  */
  static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque)
  {
@@ -156,7 +135,6 @@ static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque)
      }
      return 0;
  }
-#endif
 
  /* Called from curl_multi_do_locked, with s->mutex held.  */
  static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
@@ -433,7 +411,6 @@ static void curl_multi_do(void *arg)
 
  static void curl_multi_timeout_do(void *arg)
  {
-#ifdef NEED_CURL_TIMER_CALLBACK
      BDRVCURLState *s = (BDRVCURLState *)arg;
      int running;
 
@@ -446,9 +423,6 @@ static void curl_multi_timeout_do(void *arg)
 
      curl_multi_check_completion(s);
      qemu_mutex_unlock(&s->mutex);
-#else
-    abort();
-#endif
  }
 
  /* Called with s->mutex held.  */
@@ -598,10 +572,8 @@ static void curl_attach_aio_context(BlockDriverState *bs,
      s->multi = curl_multi_init();
      s->aio_context = new_context;
      curl_multi_setopt(s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb);
-#ifdef NEED_CURL_TIMER_CALLBACK
      curl_multi_setopt(s->multi, CURLMOPT_TIMERDATA, s);
      curl_multi_setopt(s->multi, CURLMOPT_TIMERFUNCTION, curl_timer_cb);
-#endif
  }
 
  static QemuOptsList runtime_opts = {
Signature · 1 line
2.28.0

Regards,
Daniel

#3 lore raw
Quoted 14 lines · Paolo Bonzini
Quoted 13 lines · Daniel P. Berrangé
Quoted 2 lines · Paolo Bonzini

cURL 7.16.0 was released in October 2006. Just remove code that is in all likelihood not being used anywhere.

Rather than assuming that, we should be picking our minimum version and enforcing that in configure/meson.

Currently, we have a manual code compile check for curl_multi_setopt, after doing a pkg-config check with no min version.

We should set a min version in pkg-config and drop the compile check in configure.

Quoted 7 lines
Quoted 2 lines

Based on repology.org and our platform support matrix, RHEL-7 looks like the oldest curl that we need to care about, 7.29.0

That is complicated a bit by the fact that curl is detected with both pkg-config and curl-config. That is probably unnecessary too, since we do not need any of the options that are exclusive to curl-config, such as --ca. If we can drop curl-config, moving the detection to meson is much easier.

That's just another bit of historical cruft - use of curl-config dates back to when you introduced pkg-config for curl in 2010, to cope with distros that didn't ship pkg-config files yet. Our supported platforms today will all have pkg-config for curl, so we can drop curl-config too.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|