#include <XrdClHttpUtil.hh>
HandlerQueue is a deque of curl operations that need to be performed. The object is thread safe and can be waited on via poll().
The fact that it's poll'able is necessary because the multi-curl driver thread is based on polling FD's
Definition at line 167 of file XrdClHttpUtil.hh.
◆ HandlerQueue()
| HandlerQueue::HandlerQueue |
( |
unsigned |
max_pending_ops | ) |
|
Definition at line 559 of file XrdClHttpUtil.cc.
560 m_max_pending_ops(max_pending_ops)
563 auto result = pipe(filedes);
565 throw std::runtime_error(strerror(errno));
567 if (fcntl(filedes[0], F_SETFL, O_NONBLOCK | O_CLOEXEC) == -1 || fcntl(filedes[1], F_SETFL, O_NONBLOCK | O_CLOEXEC) == -1) {
570 throw std::runtime_error(strerror(errno));
572 m_read_fd = filedes[0];
573 m_write_fd = filedes[1];
References close.
◆ Consume()
| std::shared_ptr< CurlOperation > HandlerQueue::Consume |
( |
std::chrono::steady_clock::duration |
dur | ) |
|
Definition at line 792 of file XrdClHttpUtil.cc.
794 std::unique_lock<std::mutex> lk(m_mutex);
795 m_consumer_cv.wait_for(lk, dur, [&]{
return m_ops.size() > 0 || m_shutdown;});
796 if (m_shutdown || m_ops.empty()) {
800 std::shared_ptr<CurlOperation> result = m_ops.front();
805 auto result =
read(m_read_fd, ready, 1);
807 if (errno == EINTR) {
809 }
else if (errno == EAGAIN || errno == EWOULDBLOCK) {
814 throw std::runtime_error(strerror(errno));
820 m_producer_cv.notify_one();
821 m_ops_consumed.fetch_add(1, std::memory_order_relaxed);
ssize_t read(int fildes, void *buf, size_t nbyte)
References read().
◆ Expire()
| void HandlerQueue::Expire |
( |
| ) |
|
Definition at line 691 of file XrdClHttpUtil.cc.
693 std::unique_lock<std::mutex> lk(m_mutex);
694 auto now = std::chrono::steady_clock::now();
697 for (
auto &op : m_ops) {
698 if (!op->IsPaused())
continue;
700 if (op->TransferStalled(0, now)) {
701 op->ContinueHandle();
705 std::vector<decltype(m_ops)::value_type> expired_ops;
706 unsigned expired_count = 0;
707 auto it = std::remove_if(m_ops.begin(), m_ops.end(),
708 [&](
const std::shared_ptr<CurlOperation> &handler) {
709 auto expired = handler->GetOperationExpiry() < now;
711 expired_ops.push_back(handler);
716 m_ops.erase(it, m_ops.end());
721 unsigned bytes_to_read = expired_count;
722 while (bytes_to_read > 0) {
723 size_t chunk = std::min<size_t>(
sizeof(throwaway), bytes_to_read);
724 ssize_t n =
read(m_read_fd, throwaway, chunk);
727 }
else if (n == -1) {
728 if (errno == EINTR) {
748 for (
auto &handler : expired_ops) {
const uint16_t errOperationExpired
◆ GetDefaultMaxPendingOps()
| static unsigned XrdClHttp::HandlerQueue::GetDefaultMaxPendingOps |
( |
| ) |
|
|
inlinestatic |
◆ GetHandle()
| CURL * HandlerQueue::GetHandle |
( |
| ) |
|
◆ GetMonitoringJson()
| std::string HandlerQueue::GetMonitoringJson |
( |
| ) |
|
|
static |
Definition at line 827 of file XrdClHttpUtil.cc.
829 auto consumed = m_ops_consumed.load(std::memory_order_relaxed);
830 auto produced = m_ops_produced.load(std::memory_order_relaxed);
832 "\"produced\":" + std::to_string(produced) +
","
833 "\"consumed\":" + std::to_string(consumed) +
","
834 "\"pending\":" + std::to_string(produced - consumed) +
","
835 "\"rejected\":" + std::to_string(m_ops_rejected.load(std::memory_order_relaxed)) +
◆ PollFD()
| int XrdClHttp::HandlerQueue::PollFD |
( |
| ) |
const |
|
inline |
◆ Produce()
| void HandlerQueue::Produce |
( |
std::shared_ptr< CurlOperation > |
handler | ) |
|
Definition at line 754 of file XrdClHttpUtil.cc.
756 auto handler_expiry = handler->GetOperationExpiry();
757 std::unique_lock<std::mutex> lk{m_mutex};
758 m_producer_cv.wait_until(lk,
760 [&]{
return m_ops.size() < m_max_pending_ops;}
762 if (std::chrono::steady_clock::now() > handler_expiry) {
765 m_ops_rejected.fetch_add(1, std::memory_order_relaxed);
769 m_ops.push_back(handler);
772 auto result =
write(m_write_fd, ready, 1);
774 if (errno == EINTR) {
776 }
else if (errno == EAGAIN || errno == EWOULDBLOCK) {
781 throw std::runtime_error(strerror(errno));
787 m_consumer_cv.notify_one();
788 m_ops_produced.fetch_add(1, std::memory_order_relaxed);
References XrdCl::errOperationExpired, and write.
◆ RecycleHandle()
| void HandlerQueue::RecycleHandle |
( |
CURL * |
curl | ) |
|
◆ ReleaseHandles()
| void HandlerQueue::ReleaseHandles |
( |
| ) |
|
Definition at line 883 of file XrdClHttpUtil.cc.
885 for (
auto handle : m_handles) {
886 curl_easy_cleanup(handle);
◆ Shutdown()
| void HandlerQueue::Shutdown |
( |
| ) |
|
Definition at line 875 of file XrdClHttpUtil.cc.
877 std::unique_lock lock(m_mutex);
879 m_consumer_cv.notify_all();
◆ TryConsume()
Definition at line 840 of file XrdClHttpUtil.cc.
842 std::unique_lock<std::mutex> lk(m_mutex);
843 if (m_ops.size() == 0) {
844 std::shared_ptr<CurlOperation> result;
848 std::shared_ptr<CurlOperation> result = m_ops.front();
853 auto result =
read(m_read_fd, ready, 1);
855 if (errno == EINTR) {
857 }
else if (errno == EAGAIN || errno == EWOULDBLOCK) {
862 throw std::runtime_error(strerror(errno));
868 m_producer_cv.notify_one();
869 m_ops_consumed.fetch_add(1, std::memory_order_relaxed);
References read().
The documentation for this class was generated from the following files: