42 TPCRequest(
const std::string &label,
const int scitag,
CURL *handle) : m_label(label), m_scitag(scitag), m_curl(handle) {}
44 int WaitFor(std::chrono::steady_clock::duration);
50 void SetDone(
int status,
const std::string &msg);
54 static std::string
GenerateIdentifier(
const std::string& label,
const char *vorg,
const int scitag);
57 std::atomic<bool> m_active{
false};
59 std::string m_conn_list;
60 std::mutex m_conn_mutex;
61 std::atomic<off_t> m_progress_offset{0};
67 std::condition_variable m_cv;
69 std::string m_message;
77 void SetMaxWorkers(
unsigned max_workers) { m_max_workers = max_workers; }
87 bool Produce(TPCRequest &handler);
88 TPCRequest *TryConsume();
89 TPCRequest *ConsumeUntil(std::chrono::steady_clock::duration dur, TPCWorker *worker);
90 void Done(TPCWorker *);
91 bool IsDone()
const {
return m_done; }
94 class TPCWorker final {
96 TPCWorker(
const std::string &label,
int scitag, TPCQueue &queue);
97 TPCWorker(
const TPCWorker &) =
delete;
100 static void RunStatic(TPCWorker *myself);
102 bool IsIdle()
const {
return m_idle; }
103 void SetIdle(
bool idle) { m_idle = idle; }
104 std::condition_variable m_cv;
106 static int closesocket_callback(
void *clientp, curl_socket_t fd);
107 static int opensocket_callback(
void *clientp, curlsocktype purpose,
struct curl_sockaddr *address);
108 static int sockopt_callback(
void *clientp, curl_socket_t curlfd, curlsocktype purpose);
109 std::string getLabel()
const {
return m_label; }
112 bool RunCurl(CURLM *multi_handle, TPCRequest &request);
116 const std::string m_label;
118 XrdNetPMark *m_pmark_handle;
119 XrdHttpTpc::PMarkManager m_pmark_manager;
122 static const long CONNECT_TIMEOUT = 60;
125 const std::string m_identifier;
126 std::vector<std::unique_ptr<TPCWorker>> m_workers;
127 std::deque<TPCRequest *> m_ops;
132 void Done(
const std::string &ident);
134 static std::shared_mutex m_mutex;
136 static std::chrono::steady_clock::duration m_idle_timeout;
137 static std::unordered_map<std::string, std::shared_ptr<TPCQueue>> m_pool_map;
138 static unsigned m_max_pending_ops;
139 static unsigned m_max_workers;
140 static std::once_flag m_init_once;