From 0348d2db58676b1bb0ff0f90aea5f0e68464b4f3 Mon Sep 17 00:00:00 2001 From: Brian Bockelman Date: Wed, 25 Mar 2020 22:38:28 -0500 Subject: [PATCH] Avoid old versions of libcurl that do not support CURLINFO_PRIMARY_PORT --- src/XrdTpc/XrdTpcState.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/XrdTpc/XrdTpcState.cc b/src/XrdTpc/XrdTpcState.cc index 17471734e5d..3855175c7a4 100644 --- a/src/XrdTpc/XrdTpcState.cc +++ b/src/XrdTpc/XrdTpcState.cc @@ -264,6 +264,9 @@ bool State::Finalize() std::string State::GetConnectionDescription() { + // CURLINFO_PRIMARY_PORT is only defined for 7.21.0 or later; on older + // library versions, simply omit this information. +#if LIBCURL_VERSION_NUM >= 0x071500 char *curl_ip = NULL; CURLcode rc = curl_easy_getinfo(m_curl, CURLINFO_PRIMARY_IP, &curl_ip); if ((rc != CURLE_OK) || !curl_ip) { @@ -278,11 +281,14 @@ std::string State::GetConnectionDescription() // libcurl returns IPv6 addresses of the form: // 2600:900:6:1301:5054:ff:fe0b:9cba:8000 // However the HTTP-TPC spec says to use the form - // [2600:900:6:1301:5054:ff:fe0b:9cba:8000] + // [2600:900:6:1301:5054:ff:fe0b:9cba]:8000 // Hence, we add '[' and ']' whenever a ':' is seen. if (NULL == strchr(curl_ip, ':')) ss << "tcp:" << curl_ip << ":" << curl_port; else ss << "tcp:[" << curl_ip << "]:" << curl_port; return ss.str(); +#else + return ""; +#endif }