XRootD
TPC::TPCRequestManager::TPCRequest Class Reference

#include <XrdHttpTpcPool.hh>

+ Collaboration diagram for TPC::TPCRequestManager::TPCRequest:

Public Member Functions

 TPCRequest (const std::string &label, const int scitag, CURL *handle)
 
void Cancel ()
 
CURLGetHandle () const
 
std::string GetLabel () const
 
std::string GetRemoteConnDesc ()
 
int GetScitag () const
 
bool IsActive () const
 
void SetActive ()
 
void SetDone (int status, const std::string &msg)
 
void UpdateRemoteConnDesc ()
 
int WaitFor (std::chrono::steady_clock::duration)
 

Static Public Member Functions

static std::string GenerateIdentifier (const std::string &label, const char *vorg, const int scitag)
 

Detailed Description

Definition at line 40 of file XrdHttpTpcPool.hh.

Constructor & Destructor Documentation

◆ TPCRequest()

TPC::TPCRequestManager::TPCRequest::TPCRequest ( const std::string &  label,
const int  scitag,
CURL handle 
)
inline

Definition at line 42 of file XrdHttpTpcPool.hh.

42 : m_label(label), m_scitag(scitag), m_curl(handle) {}

Member Function Documentation

◆ Cancel()

void TPCRequestManager::TPCRequest::Cancel ( )

Definition at line 318 of file XrdHttpTpcPool.cc.

318 { m_active.store(false, std::memory_order_relaxed); }

◆ GenerateIdentifier()

std::string TPCRequestManager::TPCRequest::GenerateIdentifier ( const std::string &  label,
const char *  vorg,
const int  scitag 
)
static

Definition at line 328 of file XrdHttpTpcPool.cc.

328  {
329  std::stringstream ss;
330  ss << label; // always present
331 
332  if (vorg && *vorg) {
333  ss << "_" << vorg;
334  }
335 
336  if (scitag != -1) {
337  ss << "_" << scitag;
338  }
339  return ss.str();
340 }

◆ GetHandle()

CURL * TPCRequestManager::TPCRequest::GetHandle ( ) const

Definition at line 320 of file XrdHttpTpcPool.cc.

320 { return m_curl; }

◆ GetLabel()

std::string TPCRequestManager::TPCRequest::GetLabel ( ) const

Definition at line 326 of file XrdHttpTpcPool.cc.

326 { return m_label; }

Referenced by TPC::TPCRequestManager::Produce().

+ Here is the caller graph for this function:

◆ GetRemoteConnDesc()

std::string TPCRequestManager::TPCRequest::GetRemoteConnDesc ( )

Definition at line 377 of file XrdHttpTpcPool.cc.

377  {
378  std::unique_lock<std::mutex> lock(m_conn_mutex);
379  return m_conn_list;
380 }

◆ GetScitag()

int TPCRequestManager::TPCRequest::GetScitag ( ) const

Definition at line 322 of file XrdHttpTpcPool.cc.

322 { return m_scitag; }

◆ IsActive()

bool TPCRequestManager::TPCRequest::IsActive ( ) const

Definition at line 324 of file XrdHttpTpcPool.cc.

324 { return m_active.load(std::memory_order_relaxed); }

◆ SetActive()

void TPCRequestManager::TPCRequest::SetActive ( )

Definition at line 316 of file XrdHttpTpcPool.cc.

316 { m_active.store(true, std::memory_order_relaxed); }

◆ SetDone()

void TPCRequestManager::TPCRequest::SetDone ( int  status,
const std::string &  msg 
)

Definition at line 382 of file XrdHttpTpcPool.cc.

382  {
383  std::unique_lock<std::mutex> lock(m_mutex);
384  m_status = status;
385  m_message = msg;
386  m_cv.notify_one();
387 }

◆ UpdateRemoteConnDesc()

void TPCRequestManager::TPCRequest::UpdateRemoteConnDesc ( )

Definition at line 343 of file XrdHttpTpcPool.cc.

343  {
344 #if LIBCURL_VERSION_NUM >= 0x071500
345  // Retrieve IP address and port from the curl handle
346  const char *curl_ip = nullptr;
347  CURLcode rc = curl_easy_getinfo(m_curl, CURLINFO_PRIMARY_IP, &curl_ip);
348  if (rc != CURLE_OK || !curl_ip) {
349  return; // Failed to get IP, cannot update connection descriptor
350  }
351 
352  long curl_port = 0;
353  rc = curl_easy_getinfo(m_curl, CURLINFO_PRIMARY_PORT, &curl_port);
354  if (rc != CURLE_OK || curl_port == 0) {
355  return; // Failed to get port, cannot update connection descriptor
356  }
357 
358  // Format the connection string according to HTTP-TPC spec
359  // IPv6 addresses must be enclosed in square brackets
360  std::stringstream ss;
361  if (strchr(curl_ip, ':') == nullptr) {
362  ss << "tcp:" << curl_ip << ":" << curl_port;
363  } else {
364  ss << "tcp:[" << curl_ip << "]:" << curl_port;
365  }
366 
367  {
368  std::unique_lock<std::mutex> lock(m_conn_mutex);
369  m_conn_list = ss.str();
370  }
371 #else
372  // For older libcurl versions, do nothing
373  return;
374 #endif
375 }

◆ WaitFor()

int TPCRequestManager::TPCRequest::WaitFor ( std::chrono::steady_clock::duration  dur)

Definition at line 389 of file XrdHttpTpcPool.cc.

389  {
390  std::unique_lock<std::mutex> lock(m_mutex);
391  m_cv.wait_for(lock, dur, [&] { return m_status >= 0; });
392 
393  return m_status;
394 }

The documentation for this class was generated from the following files: