Skip to content

Commit dad598d

Browse files
authored
Merge pull request ceph#45214 from cbodley/wip-rgw-ancient-curl-workaround
cmake/rgw: remove workaround for ancient libcurl Reviewed-by: Yehuda Sadeh <[email protected]>
2 parents 7eaed47 + 12555ea commit dad598d

File tree

4 files changed

+4
-146
lines changed

4 files changed

+4
-146
lines changed

CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,8 @@ else()
363363
set(EXE_LINKER_USE_PIE ${ENABLE_SHARED})
364364
endif()
365365

366-
find_package(CURL REQUIRED)
367-
set(CMAKE_REQUIRED_INCLUDES ${CURL_INCLUDE_DIRS})
368-
set(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBRARIES})
369-
CHECK_SYMBOL_EXISTS(curl_multi_wait curl/curl.h HAVE_CURL_MULTI_WAIT)
366+
# require libcurl with good curl_multi_wait(), see https://tracker.ceph.com/issues/15915
367+
find_package(CURL 7.32 REQUIRED)
370368

371369
find_package(OpenSSL REQUIRED)
372370
set(CRYPTO_LIBS OpenSSL::Crypto)

src/include/config-h.in.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@
121121
#cmakedefine HAVE_LIBTCMALLOC
122122
#cmakedefine LIBTCMALLOC_MISSING_ALIGNED_ALLOC
123123

124-
/* Define if have curl_multi_wait() */
125-
#cmakedefine HAVE_CURL_MULTI_WAIT 1
126-
127124
/* AsyncMessenger RDMA conditional compilation */
128125
#cmakedefine HAVE_RDMA
129126

src/rgw/rgw_http_client.cc

Lines changed: 2 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -721,8 +721,7 @@ int RGWHTTPTransceiver::send_data(void* ptr, size_t len, bool* pause)
721721
static int clear_signal(int fd)
722722
{
723723
// since we're in non-blocking mode, we can try to read a lot more than
724-
// one signal from signal_thread() to avoid later wakeups. non-blocking reads
725-
// are also required to support the curl_multi_wait bug workaround
724+
// one signal from signal_thread() to avoid later wakeups
726725
std::array<char, 256> buf{};
727726
int ret = ::read(fd, (void *)buf.data(), buf.size());
728727
if (ret < 0) {
@@ -732,68 +731,6 @@ static int clear_signal(int fd)
732731
return 0;
733732
}
734733

735-
#if HAVE_CURL_MULTI_WAIT
736-
737-
static std::once_flag detect_flag;
738-
static bool curl_multi_wait_bug_present = false;
739-
740-
static int detect_curl_multi_wait_bug(CephContext *cct, CURLM *handle,
741-
int write_fd, int read_fd)
742-
{
743-
int ret = 0;
744-
745-
// write to write_fd so that read_fd becomes readable
746-
uint32_t buf = 0;
747-
ret = ::write(write_fd, &buf, sizeof(buf));
748-
if (ret < 0) {
749-
ret = -errno;
750-
ldout(cct, 0) << "ERROR: " << __func__ << "(): write() returned " << ret << dendl;
751-
return ret;
752-
}
753-
754-
// pass read_fd in extra_fds for curl_multi_wait()
755-
int num_fds;
756-
struct curl_waitfd wait_fd;
757-
758-
wait_fd.fd = read_fd;
759-
wait_fd.events = CURL_WAIT_POLLIN;
760-
wait_fd.revents = 0;
761-
762-
ret = curl_multi_wait(handle, &wait_fd, 1, 0, &num_fds);
763-
if (ret != CURLM_OK) {
764-
ldout(cct, 0) << "ERROR: curl_multi_wait() returned " << ret << dendl;
765-
return -EIO;
766-
}
767-
768-
// curl_multi_wait should flag revents when extra_fd is readable. if it
769-
// doesn't, the bug is present and we can't rely on revents
770-
if (wait_fd.revents == 0) {
771-
curl_multi_wait_bug_present = true;
772-
ldout(cct, 0) << "WARNING: detected a version of libcurl which contains a "
773-
"bug in curl_multi_wait(). enabling a workaround that may degrade "
774-
"performance slightly." << dendl;
775-
}
776-
777-
return clear_signal(read_fd);
778-
}
779-
780-
static bool is_signaled(const curl_waitfd& wait_fd)
781-
{
782-
if (wait_fd.fd < 0) {
783-
// no fd to signal
784-
return false;
785-
}
786-
787-
if (curl_multi_wait_bug_present) {
788-
// we can't rely on revents, so we always return true if a wait_fd is given.
789-
// this means we'll be trying a non-blocking read on this fd every time that
790-
// curl_multi_wait() wakes up
791-
return true;
792-
}
793-
794-
return wait_fd.revents > 0;
795-
}
796-
797734
static int do_curl_wait(CephContext *cct, CURLM *handle, int signal_fd)
798735
{
799736
int num_fds;
@@ -809,72 +746,16 @@ static int do_curl_wait(CephContext *cct, CURLM *handle, int signal_fd)
809746
return -EIO;
810747
}
811748

812-
if (is_signaled(wait_fd)) {
813-
ret = clear_signal(signal_fd);
814-
if (ret < 0) {
815-
ldout(cct, 0) << "ERROR: " << __func__ << "(): read() returned " << ret << dendl;
816-
return ret;
817-
}
818-
}
819-
return 0;
820-
}
821-
822-
#else
823-
824-
static int do_curl_wait(CephContext *cct, CURLM *handle, int signal_fd)
825-
{
826-
fd_set fdread;
827-
fd_set fdwrite;
828-
fd_set fdexcep;
829-
int maxfd = -1;
830-
831-
FD_ZERO(&fdread);
832-
FD_ZERO(&fdwrite);
833-
FD_ZERO(&fdexcep);
834-
835-
/* get file descriptors from the transfers */
836-
int ret = curl_multi_fdset(handle, &fdread, &fdwrite, &fdexcep, &maxfd);
837-
if (ret) {
838-
ldout(cct, 0) << "ERROR: curl_multi_fdset returned " << ret << dendl;
839-
return -EIO;
840-
}
841-
842-
if (signal_fd > 0) {
843-
FD_SET(signal_fd, &fdread);
844-
if (signal_fd >= maxfd) {
845-
maxfd = signal_fd + 1;
846-
}
847-
}
848-
849-
/* forcing a strict timeout, as the returned fdsets might not reference all fds we wait on */
850-
uint64_t to = cct->_conf->rgw_curl_wait_timeout_ms;
851-
#define RGW_CURL_TIMEOUT 1000
852-
if (!to)
853-
to = RGW_CURL_TIMEOUT;
854-
struct timeval timeout;
855-
timeout.tv_sec = to / 1000;
856-
timeout.tv_usec = to % 1000;
857-
858-
ret = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
859-
if (ret < 0) {
860-
ret = -errno;
861-
ldout(cct, 0) << "ERROR: select returned " << ret << dendl;
862-
return ret;
863-
}
864-
865-
if (signal_fd > 0 && FD_ISSET(signal_fd, &fdread)) {
749+
if (wait_fd.revents > 0) {
866750
ret = clear_signal(signal_fd);
867751
if (ret < 0) {
868752
ldout(cct, 0) << "ERROR: " << __func__ << "(): read() returned " << ret << dendl;
869753
return ret;
870754
}
871755
}
872-
873756
return 0;
874757
}
875758

876-
#endif
877-
878759
void *RGWHTTPManager::ReqsThread::entry()
879760
{
880761
manager->reqs_thread_entry();
@@ -1174,14 +1055,6 @@ int RGWHTTPManager::start()
11741055
return -e;
11751056
}
11761057

1177-
#ifdef HAVE_CURL_MULTI_WAIT
1178-
// on first initialization, use this pipe to detect whether we're using a
1179-
// buggy version of libcurl
1180-
std::call_once(detect_flag, detect_curl_multi_wait_bug, cct,
1181-
static_cast<CURLM*>(multi_handle),
1182-
thread_pipe[1], thread_pipe[0]);
1183-
#endif
1184-
11851058
is_started = true;
11861059
reqs_thread = new ReqsThread(this);
11871060
reqs_thread->create("http_manager");

src/rgw/rgw_http_client_curl.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,6 @@ void init_ssl(){
6666
namespace rgw {
6767
namespace curl {
6868

69-
static void check_curl()
70-
{
71-
#ifndef HAVE_CURL_MULTI_WAIT
72-
derr << "WARNING: libcurl doesn't support curl_multi_wait()" << dendl;
73-
derr << "WARNING: cross zone / region transfer performance may be affected" << dendl;
74-
#endif
75-
}
76-
7769
#if defined(WITH_CURL_OPENSSL) && OPENSSL_API_COMPAT < 0x10100000L
7870
void init_ssl() {
7971
::openssl::init_ssl();
@@ -100,8 +92,6 @@ bool fe_inits_ssl(boost::optional <const fe_map_t&> m, long& curl_global_flags){
10092
std::once_flag curl_init_flag;
10193

10294
void setup_curl(boost::optional<const fe_map_t&> m) {
103-
check_curl();
104-
10595
long curl_global_flags = CURL_GLOBAL_ALL;
10696

10797
#if defined(WITH_CURL_OPENSSL) && OPENSSL_API_COMPAT < 0x10100000L

0 commit comments

Comments
 (0)