XRootD
XrdTpc::PMarkManager Class Reference

#include <XrdTpcPMarkManager.hh>

+ Collaboration diagram for XrdTpc::PMarkManager:

Classes

class  SocketInfo
 

Public Member Functions

 PMarkManager (XrdHttpExtReq &req)
 
virtual ~PMarkManager ()=default
 
void beginPMarks ()
 
bool connect (int fd, const struct sockaddr *sockP, size_t sockPLen, uint32_t timeout_sec, std::stringstream &err)
 
void endPmark (int fd)
 
bool isEnabled () const
 
void startTransfer ()
 

Detailed Description

Definition at line 48 of file XrdTpcPMarkManager.hh.

Constructor & Destructor Documentation

◆ PMarkManager()

XrdTpc::PMarkManager::PMarkManager ( XrdHttpExtReq req)

Definition at line 34 of file XrdTpcPMarkManager.cc.

34 : mPmark(req.pmark), mReq(req), mTransferWillStart(false) {}
XrdNetPMark * pmark

◆ ~PMarkManager()

virtual XrdTpc::PMarkManager::~PMarkManager ( )
virtualdefault

Member Function Documentation

◆ beginPMarks()

void XrdTpc::PMarkManager::beginPMarks ( )

Creates the different packet marking handles allowing to mark the transfer packets

Call this after the curl_multi_perform() has been called.

Definition at line 65 of file XrdTpcPMarkManager.cc.

65  {
66  if(mSocketInfos.empty()) {
67  return;
68  }
69 
70  if(mPmarkHandles.empty()) {
71  // Create the first pmark handle
72  std::stringstream ss;
73  ss << "scitag.flow=" << mReq.mSciTag;
74  SocketInfo & sockInfo = mSocketInfos.front();
75  auto pmark = mPmark->Begin(sockInfo.client, mReq.resource.c_str(), ss.str().c_str(), "http-tpc");
76  if(!pmark) {
77  return;
78  }
79  mPmarkHandles.emplace(sockInfo.client.addrInfo->SockFD(),std::unique_ptr<XrdNetPMark::Handle>(pmark));
80  mSocketInfos.pop();
81  }
82 
83  auto pmarkHandleItor = mPmarkHandles.begin();
84  while(!mSocketInfos.empty()) {
85  SocketInfo & sockInfo = mSocketInfos.front();
86  auto pmark = mPmark->Begin(*sockInfo.client.addrInfo, *(pmarkHandleItor->second), nullptr);
87  if (!pmark) {
88  // The packet marking handle could not be created from the first handle, let's retry next time
89  break;
90  }
91 
92  int fd = sockInfo.client.addrInfo->SockFD();
93  mPmarkHandles.emplace(fd, std::unique_ptr<XrdNetPMark::Handle>(pmark));
94  mSocketInfos.pop();
95  }
96 }
std::string resource
virtual Handle * Begin(XrdSecEntity &Client, const char *path=0, const char *cgi=0, const char *app=0)=0

References XrdSecEntity::addrInfo, XrdNetPMark::Begin(), XrdTpc::PMarkManager::SocketInfo::client, XrdHttpExtReq::mSciTag, XrdHttpExtReq::resource, and XrdNetAddrInfo::SockFD().

+ Here is the call graph for this function:

◆ connect()

bool XrdTpc::PMarkManager::connect ( int  fd,
const struct sockaddr *  sockP,
size_t  sockPLen,
uint32_t  timeout_sec,
std::stringstream &  err 
)

Will connect the socket attached to the file descriptor within a certain timeout and add the file descriptor to the. packet marking manager so packet marking can be done achieved later on If pmark is not enabled, this function will just return true without trying to connect (libcurl will perform the connection). False will be returned in case the connection could not have been done.

Parameters
fdthe fd associated to the socket
sockPthe connection information
sockPLenthe length of the connection information
timeout_secthe timeout after which the connection is considered failed
errthe error stream allowing to understand from where the issue comes from
Returns
true if the connection could be established or if pmark is disabled, false otherwise

Definition at line 43 of file XrdTpcPMarkManager.cc.

43  {
44  if(isEnabled()) {
45  // We only connect if the packet marking is enabled
46  bool couldConnect = XrdNetUtils::ConnectWithTimeout(fd,sockP,sockPLen,timeout_sec,err);
47  if(couldConnect) {
48  addFd(fd,sockP);
49  } else {
50  return false;
51  }
52  }
53  // If pmark is not enabled, we leave libcurl doing the connection
54  return true;
55 }
static bool ConnectWithTimeout(int sockfd, const struct sockaddr *clientAddr, size_t clientAddrLen, uint32_t timeout_sec, std::stringstream &errMsg)
Definition: XrdNetUtils.cc:946

References XrdNetUtils::ConnectWithTimeout(), and isEnabled().

+ Here is the call graph for this function:

◆ endPmark()

void XrdTpc::PMarkManager::endPmark ( int  fd)

This function deletes the PMark handle associated to the fd passed in parameter Use this before closing the associated socket! Otherwise the information contained in the firefly (e.g sent bytes or received bytes) will have values equal to 0.

Parameters
fdthe fd of the socket to be closed

Definition at line 98 of file XrdTpcPMarkManager.cc.

98  {
99  // We need to delete the PMark handle associated to the fd passed in parameter
100  // we just look for it and reset the unique_ptr to nullptr to trigger the PMark handle deletion
101  mPmarkHandles.erase(fd);
102 }

◆ isEnabled()

bool XrdTpc::PMarkManager::isEnabled ( ) const
Returns
true if packet marking can happen i.e the packet marking is enabled in the configuration and a scitag was provided by the user.

Definition at line 57 of file XrdTpcPMarkManager.cc.

57  {
58  return mPmark && (mReq.mSciTag >= 0);
59 }

References XrdHttpExtReq::mSciTag.

Referenced by connect().

+ Here is the caller graph for this function:

◆ startTransfer()

void XrdTpc::PMarkManager::startTransfer ( )

Calling this function will indicate that the connections that will happen will be related to the data transfer. The addFd(...) function will then register any socket that is created after this function will be called.

Definition at line 61 of file XrdTpcPMarkManager.cc.

61  {
62  mTransferWillStart = true;
63 }

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