#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 196 of file XrdClHttpUtil.hh.
◆ HandlerQueue()
| HandlerQueue::HandlerQueue |
( |
unsigned |
max_pending_ops | ) |
|
Definition at line 697 of file XrdClHttpUtil.cc.
698 m_max_pending_ops(max_pending_ops)
701 auto result = pipe(filedes);
703 throw std::system_error(errno, std::generic_category(),
704 "failed to create HTTP worker pipe");
706 if (fcntl(filedes[0], F_SETFL, O_NONBLOCK | O_CLOEXEC) == -1 || fcntl(filedes[1], F_SETFL, O_NONBLOCK | O_CLOEXEC) == -1) {
707 const int error = errno;
710 throw std::system_error(error, std::generic_category(),
711 "failed to configure HTTP worker pipe");
713 m_read_fd = filedes[0];
714 m_write_fd = filedes[1];
References close.
◆ Consume()
| std::shared_ptr< CurlOperation > HandlerQueue::Consume |
( |
std::chrono::steady_clock::duration |
dur | ) |
|
Definition at line 939 of file XrdClHttpUtil.cc.
941 std::unique_lock<std::mutex> lk(m_mutex);
942 m_consumer_cv.wait_for(lk, dur, [&]{
return m_ops.size() > 0 || m_shutdown;});
943 if (m_shutdown || m_ops.empty()) {
947 std::shared_ptr<CurlOperation> result = m_ops.front();
952 auto result =
read(m_read_fd, ready, 1);
954 if (errno == EINTR) {
956 }
else if (errno == EAGAIN || errno == EWOULDBLOCK) {
961 throw std::system_error(errno, std::generic_category(),
962 "failed to consume HTTP worker notification");
968 m_producer_cv.notify_one();
969 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 837 of file XrdClHttpUtil.cc.
839 std::unique_lock<std::mutex> lk(m_mutex);
840 auto now = std::chrono::steady_clock::now();
843 for (
auto &op : m_ops) {
844 if (!op->IsPaused())
continue;
846 if (op->TransferStalled(0, now)) {
847 op->ContinueHandle();
851 std::vector<decltype(m_ops)::value_type> expired_ops;
852 unsigned expired_count = 0;
853 auto it = std::remove_if(m_ops.begin(), m_ops.end(),
854 [&](
const std::shared_ptr<CurlOperation> &handler) {
855 auto expired = handler->GetOperationExpiry() < now;
857 expired_ops.push_back(handler);
862 m_ops.erase(it, m_ops.end());
867 unsigned bytes_to_read = expired_count;
868 while (bytes_to_read > 0) {
869 size_t chunk = std::min<size_t>(
sizeof(throwaway), bytes_to_read);
870 ssize_t n =
read(m_read_fd, throwaway, chunk);
873 }
else if (n == -1) {
874 if (errno == EINTR) {
894 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 975 of file XrdClHttpUtil.cc.
977 auto consumed = m_ops_consumed.load(std::memory_order_relaxed);
978 auto produced = m_ops_produced.load(std::memory_order_relaxed);
980 "\"produced\":" + std::to_string(produced) +
","
981 "\"consumed\":" + std::to_string(consumed) +
","
982 "\"pending\":" + std::to_string(produced - consumed) +
","
983 "\"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 900 of file XrdClHttpUtil.cc.
902 auto handler_expiry = handler->GetOperationExpiry();
903 std::unique_lock<std::mutex> lk{m_mutex};
904 m_producer_cv.wait_until(lk,
906 [&]{
return m_ops.size() < m_max_pending_ops;}
908 if (std::chrono::steady_clock::now() > handler_expiry) {
911 m_ops_rejected.fetch_add(1, std::memory_order_relaxed);
915 m_ops.push_back(handler);
918 auto result =
write(m_write_fd, ready, 1);
920 if (errno == EINTR) {
922 }
else if (errno == EAGAIN || errno == EWOULDBLOCK) {
927 throw std::system_error(errno, std::generic_category(),
928 "failed to notify HTTP worker");
934 m_consumer_cv.notify_one();
935 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 1032 of file XrdClHttpUtil.cc.
1034 for (
auto handle : m_handles) {
1035 curl_easy_cleanup(handle);
◆ Shutdown()
| void HandlerQueue::Shutdown |
( |
| ) |
|
Definition at line 1024 of file XrdClHttpUtil.cc.
1026 std::unique_lock lock(m_mutex);
1028 m_consumer_cv.notify_all();
◆ TryConsume()
Definition at line 988 of file XrdClHttpUtil.cc.
990 std::unique_lock<std::mutex> lk(m_mutex);
991 if (m_ops.size() == 0) {
992 std::shared_ptr<CurlOperation> result;
996 std::shared_ptr<CurlOperation> result = m_ops.front();
1001 auto result =
read(m_read_fd, ready, 1);
1003 if (errno == EINTR) {
1005 }
else if (errno == EAGAIN || errno == EWOULDBLOCK) {
1010 throw std::system_error(errno, std::generic_category(),
1011 "failed to consume HTTP worker notification");
1017 m_producer_cv.notify_one();
1018 m_ops_consumed.fetch_add(1, std::memory_order_relaxed);
References read().
The documentation for this class was generated from the following files: