xrootd
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
XrdLink Class Reference

#include <XrdLink.hh>

Inheritance diagram for XrdLink:
Inheritance graph
[legend]
Collaboration diagram for XrdLink:
Collaboration graph
[legend]

Public Types

typedef XrdOucSFVec sfVec
 

Public Member Functions

bool Activate ()
 
XrdNetAddrInfoAddrInfo ()
 
int Backlog ()
 
int Client (char *buff, int blen)
 
int Close (bool defer=false)
 
void Enable ()
 Enable the link to field interrupts.
 
int FDnum ()
 
int getIOStats (long long &inbytes, long long &outbytes, int &numstall, int &numtardy)
 
XrdTlsPeerCertsgetPeerCerts ()
 
XrdProtocolgetProtocol ()
 Obtain current protocol object pointer.
 
void Hold (bool lk)
 
const char * Host () const
 
unsigned int Inst () const
 
bool isFlawed () const
 
bool isInstance (unsigned int inst) const
 
const char * Name () const
 
const XrdNetAddrNetAddr () const
 
int Peek (char *buff, int blen, int timeout=-1)
 
int Recv (char *buff, int blen)
 
int Recv (char *buff, int blen, int timeout)
 
int Recv (const struct iovec *iov, int iocnt, int timeout)
 
int RecvAll (char *buff, int blen, int timeout=-1)
 
bool Register (const char *hName)
 
int Send (const char *buff, int blen)
 
int Send (const struct iovec *iov, int iocnt, int bytes=0)
 
int Send (const sfVec *sdP, int sdn)
 
void Serialize ()
 Wait for all outstanding requests to be completed on the link.
 
int setEtext (const char *text)
 
void setID (const char *userid, int procid)
 
void setLocation (XrdNetAddrInfo::LocInfo &loc)
 
bool setNB ()
 
XrdProtocolsetProtocol (XrdProtocol *pp, bool runit=false, bool push=false)
 
void setProtName (const char *name)
 
void setRef (int cnt)
 
bool setTLS (bool enable, XrdTlsContext *ctx=0)
 Enable or disable TLS on the link.
 
void Shutdown (bool getLock)
 
void syncStats (int *ctime=0)
 
int Terminate (const char *owner, int fdnum, unsigned int inst)
 
time_t timeCon () const
 Return the time the link was made active (i.e. time of connection).
 
int UseCnt () const
 Return link's reference count.
 
void armBridge ()
 Mark this link as an in-memory communications bridge (internal use only).
 
bool hasBridge () const
 
bool hasTLS () const
 
const char * verTLS ()
 
 XrdLink (XrdLinkXeq &lxq)
 
- Public Member Functions inherited from XrdJob
 XrdJob (const char *desc="")
 
virtual ~XrdJob ()
 

Static Public Member Functions

static XrdLinkFind (int &curr, XrdLinkMatch *who=0)
 
static int getName (int &curr, char *bname, int blen, XrdLinkMatch *who=0)
 
static int Stats (char *buff, int blen, bool do_sync=0)
 

Public Attributes

char * ID
 Pointer to the client's link identity.
 
- Public Attributes inherited from XrdJob
XrdJobNextJob
 
const char * Comment
 

Static Public Attributes

static bool sfOK
 

Protected Member Functions

 ~XrdLink ()
 
void DoIt ()
 
void ResetLink ()
 
int Wait4Data (int timeout)
 

Protected Attributes

void * rsvd1 [3]
 
XrdLinkXeqlinkXQ
 
char * HostName
 
unsigned int Instance
 
bool isBridged
 
bool isTLS
 
char rsvd2 [2]
 

Member Typedef Documentation

◆ sfVec

Constructor & Destructor Documentation

◆ XrdLink()

XrdLink::XrdLink ( XrdLinkXeq lxq)

Constructor

Parameters
lxqReference to the implementation.

◆ ~XrdLink()

XrdLink::~XrdLink ( )
inlineprotected

Member Function Documentation

◆ Activate()

bool XrdLink::Activate ( )

Activate a link by attaching it to a poller object.

Returns
True if activation succeeded and false otherwise.

◆ AddrInfo()

XrdNetAddrInfo * XrdLink::AddrInfo ( )

Obtain the address information for this link.

Returns
Pointer to the XrdAddrInfo object. The pointer is valid while the end-point is connected.

◆ armBridge()

void XrdLink::armBridge ( )

Mark this link as an in-memory communications bridge (internal use only).

◆ Backlog()

int XrdLink::Backlog ( )

Obtain the number of queued async requests.

Returns
The number of async requests queued.

◆ Client()

int XrdLink::Client ( char *  buff,
int  blen 
)

Get a copy of the client's name as known by the link.

Parameters
buffPointer to buffer to hold the name.
blenLength of the buffer.
Returns
!0 The length of the name in gthe buffer. =0 The name could not be returned.

◆ Close()

int XrdLink::Close ( bool  defer = false)

Close the link.

Parameters
deferIf true, the link is made unaccessible but the link object not the file descriptor is released.
Returns
!0 An error occurred, the return value is the errno. =0 Action successfully completed.

◆ DoIt()

void XrdLink::DoIt ( )
protectedvirtual

Implements XrdJob.

Reimplemented in XrdLinkXeq.

◆ Enable()

void XrdLink::Enable ( )

Enable the link to field interrupts.

◆ FDnum()

int XrdLink::FDnum ( )

Get the associated file descriptor.

Returns
The file descriptor number.

◆ Find()

static XrdLink * XrdLink::Find ( int &  curr,
XrdLinkMatch who = 0 
)
static

Find the next link matching certain attributes.

Parameters
currIs an internal tracking value that allows repeated calls. It must be set to a value of 0 or less on the initial call and not touched therafter unless a null pointer is returned.
whoIf the object use to check if the link matches the wanted criterea (typically, client name and host name). If the pointer is nil, the next link is always returned.
Returns
!0 Pointer to the link object that matches the criterea. The link's reference counter is increased to prevent it from being reused. A subsequent call will reduce the number. =0 No more links exist with the specified criterea.

◆ getIOStats()

int XrdLink::getIOStats ( long long &  inbytes,
long long &  outbytes,
int &  numstall,
int &  numtardy 
)

Get I/O statistics.

Parameters
inbytesThe number of bytes read.
outbytesThe number of bytes written.
numstallThe number of times the link was rescheduled due to unavailability.
numtardyThe number of times the link was delayed due to unavailability.
Returns
The link's reference count. The parameters will hold the indicated statistic.

◆ getName()

static int XrdLink::getName ( int &  curr,
char *  bname,
int  blen,
XrdLinkMatch who = 0 
)
static

Find the next client name matching certain attributes.

Parameters
currIs an internal tracking value that allows repeated calls. It must be set to a value of 0 or less on the initial call and not touched therafter unless zero is returned.
bnamePointer to a buffer where the name is to be returned.
blenThe length of the buffer.
whoIf the object use to check if the link matches the wanted criterea (typically, client name and host name). If the pointer is nil, a match always occurs.
Returns
!0 The length of teh name placed in the buffer. =0 No more links exist with the specified criterea.

◆ getPeerCerts()

XrdTlsPeerCerts * XrdLink::getPeerCerts ( )

Get the x509 certificate information for this TLS enabled link.

Returns
A pointer to the XrdTlsCerts object holding verified certificates if such certificates exist. Otherwise a nil pointer is returned.
Note
Used by various protocols, so XrdTlsPeerCerts is a private header.

◆ getProtocol()

XrdProtocol * XrdLink::getProtocol ( )

Obtain current protocol object pointer.

◆ hasBridge()

bool XrdLink::hasBridge ( ) const
inline

Determine if this link is a bridge.

Returns
true this link is a bridge.
false this link is a plain old link.

References isBridged.

◆ hasTLS()

bool XrdLink::hasTLS ( ) const
inline

Determine if this link is using TLS.

Returns
true this link is using TLS.
false this link not using TLS.

References isTLS.

◆ Hold()

void XrdLink::Hold ( bool  lk)

Lock or unlock the mutex used for control operations.

Parameters
lkWhen true, a lock is obtained. Otherwise it is released. The caller is responsible for consistency.

◆ Host()

const char * XrdLink::Host ( ) const
inline

Get the fully qualified name of the endpoint.

Returns
Pointer to fully qualified host name. The contents are valid while the endpoint is connected.

References HostName.

◆ Inst()

unsigned int XrdLink::Inst ( ) const
inline

Obtain the link's instance number.

Returns
The link's instance number.

References Instance.

◆ isFlawed()

bool XrdLink::isFlawed ( ) const

Indicate whether or not the link has an outstanding error.

Returns
True the link has an outstanding error. the link has no outstanding error.

◆ isInstance()

bool XrdLink::isInstance ( unsigned int  inst) const

Indicate whether or not this link is of a particular instance. only be used for display and not for security purposes.

Parameters
instthe expected instance number.
Returns
true the link matches the instance number. false the link differs the instance number.

◆ Name()

const char * XrdLink::Name ( ) const

Obtain the domain trimmed name of the end-point. The returned value should only be used for display and not for security purposes.

Returns
Pointer to the name that remains valid during the link's lifetime.

◆ NetAddr()

const XrdNetAddr * XrdLink::NetAddr ( ) const

Obtain the network address object for this link. The returned value is valid as long as the end-point is connected. Otherwise, it may change.

Returns
Pointer to the object and remains valid during the link's lifetime.

Referenced by XrdCmsNode::isNode().

◆ Peek()

int XrdLink::Peek ( char *  buff,
int  blen,
int  timeout = -1 
)

Issue a socket peek() and return result (do not use for TLS connections).

Parameters
buffpointer to buffer to hold data.
blenlength of buffer.
timeoutmilliseconds to wait for data. A negative value waits forever.
Returns
>=0 buffer holds data equal to the returned value. < 0 an error or timeout occurred.

◆ Recv() [1/3]

int XrdLink::Recv ( char *  buff,
int  blen 
)

Read data from a link. Note that this call blocks until some data is available. Use Recv() with a timeout to avoid blocking.

Parameters
buffpointer to buffer to hold data.
blenlength of buffer (implies the maximum bytes wanted).
Returns
>=0 buffer holds data equal to the returned value. < 0 an error occurred.

◆ Recv() [2/3]

int XrdLink::Recv ( char *  buff,
int  blen,
int  timeout 
)

Read data from a link. Note that this call either reads all the data wanted or no data if the passed timeout occurs before any data is present.

Parameters
buffpointer to buffer to hold data.
blenlength of buffer (implies the actual bytes wanted).
timeoutmilliseconds to wait for data. A negative value waits forever.
Returns
>=0 buffer holds data equal to the returned value. < 0 an error occurred. Note that a special error -ENOMSG is returned if poll() indicated data was present but no bytes were actually read.

◆ Recv() [3/3]

int XrdLink::Recv ( const struct iovec *  iov,
int  iocnt,
int  timeout 
)

Read data on a link. Note that this call either reads all the data wanted or no data if the passed timeout occurs before any data is present.

Parameters
iovpointer to the message vector.
iocntnumber of iov elements in the vector.
timeoutmilliseconds to wait for data. A negative value waits forever.
Returns
>=0 number of bytes read. < 0 an error occurred or when -ETIMEDOUT is returned, no data arrived within the timeout period. -ENOMSG is returned when poll indicated data was present but 0 bytes were read.

◆ RecvAll()

int XrdLink::RecvAll ( char *  buff,
int  blen,
int  timeout = -1 
)

Read data from a link. Note that this call reads as much data as it can or until the passed timeout has occurred.

Parameters
buffpointer to buffer to hold data.
blenlength of buffer (implies the maximum bytes wanted).
timeoutmilliseconds to wait for data. A negative value waits forever.
Returns
>=0 buffer holds data equal to the returned value. < 0 an error occurred or when -ETIMEDOUT is returned, no data arrived within the timeout period. -ENOMSG is returned when poll indicated data was present but 0 bytes were read.

◆ Register()

bool XrdLink::Register ( const char *  hName)

Register a host name with this IP address. This is not MT-safe!

Parameters
hNamepointer to a true host name which should be fully qualified. One of the IP addresses registered to this name must match the IP address associated with this object.
Returns
True: Specified name is now associated with this link. False: Nothing changed, registration could not be verified.

◆ ResetLink()

void XrdLink::ResetLink ( )
protected

◆ Send() [1/3]

int XrdLink::Send ( const char *  buff,
int  blen 
)

Send data on a link. This calls may block unless the socket was marked nonblocking. If a block would occur, the data is copied for later sending.

Parameters
buffpointer to buffer to send.
blenlength of buffer.
Returns
>=0 number of bytes sent. < 0 an error or occurred.

Referenced by XrdCmsNode::Send(), and XrdCmsNode::Send().

◆ Send() [2/3]

int XrdLink::Send ( const sfVec sdP,
int  sdn 
)

◆ Send() [3/3]

int XrdLink::Send ( const struct iovec *  iov,
int  iocnt,
int  bytes = 0 
)

Send data on a link. This calls may block unless the socket was marked nonblocking. If a block would occur, the data is copied for later sending.

Parameters
iovpointer to the message vector.
iocntnumber of iov elements in the vector.
bytesthe sum of the sizes in the vector.
Returns
>=0 number of bytes sent. < 0 an error occurred.

◆ Serialize()

void XrdLink::Serialize ( )

Wait for all outstanding requests to be completed on the link.

◆ setEtext()

int XrdLink::setEtext ( const char *  text)

Set an error indication on he link.

Parameters
texta message describing the error.
Returns
=0 message set, the link is considered in error. -1 the message pointer was nil.

◆ setID()

void XrdLink::setID ( const char *  userid,
int  procid 
)

Set the client's link identity.

Parameters
useridpointer to the client's username.
procidthe client's process id (i.e. pid).

◆ setLocation()

void XrdLink::setLocation ( XrdNetAddrInfo::LocInfo loc)

Set the client's location.

Parameters
locreference to the location information.

◆ setNB()

bool XrdLink::setNB ( )

Set the link to be non-blocking.

Returns
true mode has been set.
false mode is not supported for this operating system.

◆ setProtName()

void XrdLink::setProtName ( const char *  name)

Set the link's protocol name.

Parameters
namename of he protocol being used. The storage must be valid for the duration of the program.

◆ setProtocol()

XrdProtocol * XrdLink::setProtocol ( XrdProtocol pp,
bool  runit = false,
bool  push = false 
)

Set the link's protocol.

Parameters
pppointer to the protocol object.
runitif true, starts running the protocol.
pushif true, pushes current protocol to be the alternate one.
Returns
pointer to the previous protocol (may be nil).

◆ setRef()

void XrdLink::setRef ( int  cnt)

Set the link's parallel usage count.

Parameters
cntshould be 1 to increased the count and -1 to decrease it.

◆ setTLS()

bool XrdLink::setTLS ( bool  enable,
XrdTlsContext ctx = 0 
)

Enable or disable TLS on the link.

Parameters
enableif true, TLS is enabled if not already enabled. Otherwise, TLS is disabled and the TLS logical connection torn down. statistics may be contradictory as they are collected async.
ctxThe context to use when enabling TLS. When nil, the default context is used.
Returns
True if successful, false otherwise.

◆ Shutdown()

void XrdLink::Shutdown ( bool  getLock)

Shutdown the link but otherwise keep it intact.

Parameters
getLockif true, the operation is performed under a lock.

◆ Stats()

static int XrdLink::Stats ( char *  buff,
int  blen,
bool  do_sync = 0 
)
static

Obtain link statistics.

Parameters
buffpointer to the buffer for the xml statistics.
blenlength of the buffer.
do_syncif true, the statistics self-consistent. Otherwise, the statistics may be contradictory as they are collected async.
Returns
number of bytes placed in the buffer excluding the null byte.

◆ syncStats()

void XrdLink::syncStats ( int *  ctime = 0)

Add all local statistics to the global counters.

Parameters
ctimeif not nil, return the total connect time in seconds.

◆ Terminate()

int XrdLink::Terminate ( const char *  owner,
int  fdnum,
unsigned int  inst 
)

Terminate a connection.

Parameters
ownerpointer to the link ID representing a client who made the connection to be terminated. If nil then this is a request for the link to terminate another link, if possible.
fdnumthe file descriptor number of the link to be terminated.
instthe link's instance number.
Returns
>0 caller should wait this number of seconds and try again.
=0 link terminated.
<0 link could not be terminated: -EACCES the links was not created by the passed owner. -EPIPE link already being terminated. -ESRCH fdnum does not refer to a link. -ETIME unsuccessful, too many tries.

◆ timeCon()

time_t XrdLink::timeCon ( ) const

Return the time the link was made active (i.e. time of connection).

◆ UseCnt()

int XrdLink::UseCnt ( ) const

Return link's reference count.

◆ verTLS()

const char * XrdLink::verTLS ( )

Return TLS protocol version being used.

Returns
The TLS protocol version number. If the link is not using TLS, a null string is returned;

◆ Wait4Data()

int XrdLink::Wait4Data ( int  timeout)
protected

Member Data Documentation

◆ HostName

char* XrdLink::HostName
protected

Referenced by Host().

◆ ID

char* XrdLink::ID

Pointer to the client's link identity.

◆ Instance

unsigned int XrdLink::Instance
protected

Referenced by XrdLinkCtl::fd2link(), and Inst().

◆ isBridged

bool XrdLink::isBridged
protected

Referenced by hasBridge().

◆ isTLS

bool XrdLink::isTLS
protected

Referenced by hasTLS().

◆ linkXQ

XrdLinkXeq& XrdLink::linkXQ
protected

◆ rsvd1

void* XrdLink::rsvd1[3]
protected

◆ rsvd2

char XrdLink::rsvd2[2]
protected

◆ sfOK

bool XrdLink::sfOK
static

Send data on a link using sendfile(). This call always blocks until all data is sent. It should only be called if sfOK is true (see below).

Parameters
sdPpointer to the sendfile vector.
sdnnumber of elements in the vector.
Returns
>=0 number of bytes sent. < 0 an error occurred.

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