#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 191 of file XrdClHttpUtil.hh.
◆ HandlerQueue()
| HandlerQueue::HandlerQueue |
( |
unsigned |
max_pending_ops | ) |
|
Definition at line 684 of file XrdClHttpUtil.cc.
685 m_max_pending_ops(max_pending_ops)
688 auto result = pipe(filedes);
690 throw std::system_error(errno, std::generic_category(),
691 "failed to create HTTP worker pipe");
693 if (fcntl(filedes[0], F_SETFL, O_NONBLOCK | O_CLOEXEC) == -1 || fcntl(filedes[1], F_SETFL, O_NONBLOCK | O_CLOEXEC) == -1) {
694 const int error = errno;
697 throw std::system_error(error, std::generic_category(),
698 "failed to configure HTTP worker pipe");
700 m_read_fd = filedes[0];
701 m_write_fd = filedes[1];
References close.
◆ Consume()
| std::shared_ptr< CurlOperation > HandlerQueue::Consume |
( |
std::chrono::steady_clock::duration |
dur | ) |
|
Definition at line 926 of file XrdClHttpUtil.cc.
928 std::unique_lock<std::mutex> lk(m_mutex);
929 m_consumer_cv.wait_for(lk, dur, [&]{
return m_ops.size() > 0 || m_shutdown;});
930 if (m_shutdown || m_ops.empty()) {
934 std::shared_ptr<CurlOperation> result = m_ops.front();
939 auto result =
read(m_read_fd, ready, 1);
941 if (errno == EINTR) {
943 }
else if (errno == EAGAIN || errno == EWOULDBLOCK) {
948 throw std::system_error(errno, std::generic_category(),
949 "failed to consume HTTP worker notification");
955 m_producer_cv.notify_one();
956 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 824 of file XrdClHttpUtil.cc.
826 std::unique_lock<std::mutex> lk(m_mutex);
827 auto now = std::chrono::steady_clock::now();
830 for (
auto &op : m_ops) {
831 if (!op->IsPaused())
continue;
833 if (op->TransferStalled(0, now)) {
834 op->ContinueHandle();
838 std::vector<decltype(m_ops)::value_type> expired_ops;
839 unsigned expired_count = 0;
840 auto it = std::remove_if(m_ops.begin(), m_ops.end(),
841 [&](
const std::shared_ptr<CurlOperation> &handler) {
842 auto expired = handler->GetOperationExpiry() < now;
844 expired_ops.push_back(handler);
849 m_ops.erase(it, m_ops.end());
854 unsigned bytes_to_read = expired_count;
855 while (bytes_to_read > 0) {
856 size_t chunk = std::min<size_t>(
sizeof(throwaway), bytes_to_read);
857 ssize_t n =
read(m_read_fd, throwaway, chunk);
860 }
else if (n == -1) {
861 if (errno == EINTR) {
881 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 962 of file XrdClHttpUtil.cc.
964 auto consumed = m_ops_consumed.load(std::memory_order_relaxed);
965 auto produced = m_ops_produced.load(std::memory_order_relaxed);
967 "\"produced\":" + std::to_string(produced) +
","
968 "\"consumed\":" + std::to_string(consumed) +
","
969 "\"pending\":" + std::to_string(produced - consumed) +
","
970 "\"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 887 of file XrdClHttpUtil.cc.
889 auto handler_expiry = handler->GetOperationExpiry();
890 std::unique_lock<std::mutex> lk{m_mutex};
891 m_producer_cv.wait_until(lk,
893 [&]{
return m_ops.size() < m_max_pending_ops;}
895 if (std::chrono::steady_clock::now() > handler_expiry) {
898 m_ops_rejected.fetch_add(1, std::memory_order_relaxed);
902 m_ops.push_back(handler);
905 auto result =
write(m_write_fd, ready, 1);
907 if (errno == EINTR) {
909 }
else if (errno == EAGAIN || errno == EWOULDBLOCK) {
914 throw std::system_error(errno, std::generic_category(),
915 "failed to notify HTTP worker");
921 m_consumer_cv.notify_one();
922 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 1019 of file XrdClHttpUtil.cc.
1021 for (
auto handle : m_handles) {
1022 curl_easy_cleanup(handle);
◆ Shutdown()
| void HandlerQueue::Shutdown |
( |
| ) |
|
Definition at line 1011 of file XrdClHttpUtil.cc.
1013 std::unique_lock lock(m_mutex);
1015 m_consumer_cv.notify_all();
◆ TryConsume()
Definition at line 975 of file XrdClHttpUtil.cc.
977 std::unique_lock<std::mutex> lk(m_mutex);
978 if (m_ops.size() == 0) {
979 std::shared_ptr<CurlOperation> result;
983 std::shared_ptr<CurlOperation> result = m_ops.front();
988 auto result =
read(m_read_fd, ready, 1);
990 if (errno == EINTR) {
992 }
else if (errno == EAGAIN || errno == EWOULDBLOCK) {
997 throw std::system_error(errno, std::generic_category(),
998 "failed to consume HTTP worker notification");
1004 m_producer_cv.notify_one();
1005 m_ops_consumed.fetch_add(1, std::memory_order_relaxed);
References read().
The documentation for this class was generated from the following files: