@@ -721,8 +721,7 @@ int RGWHTTPTransceiver::send_data(void* ptr, size_t len, bool* pause)
721721static 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-
797734static 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-
878759void *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" );
0 commit comments