Merge branch 'wip-http-swift' of https://github.com/l-mb/fio
authorJens Axboe <axboe@kernel.dk>
Thu, 16 Aug 2018 16:38:41 +0000 (10:38 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 16 Aug 2018 16:38:41 +0000 (10:38 -0600)
* 'wip-http-swift' of https://github.com/l-mb/fio:
  engines/http: Add support for Swift storage backend

configure
engines/http.c

index 103ea945d7af423067214d81a72fcbaf8923769a..0637b105fb2a36ef0f0c296fb15d2ec5aa884eb4 100755 (executable)
--- a/configure
+++ b/configure
@@ -1573,26 +1573,11 @@ print_config "IPv6 helpers" "$ipv6"
 if test "$http" != "yes" ; then
   http="no"
 fi
-cat > $TMPC << EOF
-#include <curl/curl.h>
-#include <openssl/hmac.h>
-
-int main(int argc, char **argv)
-{
-  CURL *curl;
-  HMAC_CTX *ctx;
-
-  curl = curl_easy_init();
-  curl_easy_cleanup(curl);
-
-  ctx = HMAC_CTX_new();
-  HMAC_CTX_reset(ctx);
-  HMAC_CTX_free(ctx);
-  return 0;
-}
-EOF
-if test "$disable_http" != "yes"  && compile_prog "" "-lcurl -lssl -lcrypto" "curl"; then
-  LIBS="-lcurl -lssl -lcrypto $LIBS"
+if test "$disable_http" != "yes"  && $(pkg-config --exists libcurl openssl); then
+  if $(pkg-config --atleast-version=1.1.0 openssl); then
+    output_sym "CONFIG_HAVE_OPAQUE_HMAC_CTX"
+  fi
+  LIBS="$(pkg-config --libs libcurl openssl) $LIBS"
   http="yes"
 fi
 print_config "http engine" "$http"
index f3dfab38fecc453ae35edd2d2e26ce347607f118..cb66ebe663ee7d28cbd06b0e4fc1e06049066bbb 100644 (file)
@@ -263,14 +263,25 @@ static char *_gen_hex_md5(const char *p, size_t len)
 }
 
 static void _hmac(unsigned char *md, void *key, int key_len, char *data) {
+#ifndef CONFIG_HAVE_OPAQUE_HMAC_CTX
+       HMAC_CTX _ctx;
+#endif
        HMAC_CTX *ctx;
        unsigned int hmac_len;
 
+#ifdef CONFIG_HAVE_OPAQUE_HMAC_CTX
        ctx = HMAC_CTX_new();
+#else
+       ctx = &_ctx;
+#endif
        HMAC_Init_ex(ctx, key, key_len, EVP_sha256(), NULL);
        HMAC_Update(ctx, (unsigned char*)data, strlen(data));
        HMAC_Final(ctx, md, &hmac_len);
+#ifdef CONFIG_HAVE_OPAQUE_HMAC_CTX
        HMAC_CTX_free(ctx);
+#else
+       HMAC_CTX_cleanup(ctx);
+#endif
 }
 
 static int _curl_trace(CURL *handle, curl_infotype type,
@@ -575,7 +586,7 @@ static int fio_http_setup(struct thread_data *td)
 {
        struct http_data *http = NULL;
        struct http_options *o = td->eo;
-       int r;
+
        /* allocate engine specific structure to deal with libhttp. */
        http = calloc(1, sizeof(*http));
        if (!http) {
@@ -612,7 +623,7 @@ static int fio_http_setup(struct thread_data *td)
        return 0;
 cleanup:
        fio_http_cleanup(td);
-       return r;
+       return 1;
 }
 
 static int fio_http_open(struct thread_data *td, struct fio_file *f)