XrdLink Class Reference

#include <XrdLink.hh>

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

List of all members.

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 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)

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.

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


Constructor & Destructor Documentation

XrdLink::XrdLink ( XrdLinkXeq lxq  ) 

Constructor

Parameters:
lxq Reference to the implementation.
XrdLink::~XrdLink (  )  [inline, protected]

Member Function Documentation

bool XrdLink::Activate (  ) 

Activate a link by attaching it to a poller object.

Returns:
True if activation succeeded and false otherwise.
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.

Reimplemented in XrdLinkXeq.

void XrdLink::armBridge (  ) 

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

int XrdLink::Backlog (  ) 

Obtain the number of queued async requests.

Returns:
The number of async requests queued.

Reimplemented in XrdLinkXeq.

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

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

Parameters:
buff Pointer to buffer to hold the name.
blen Length of the buffer.
Returns:
!0 The length of the name in gthe buffer. =0 The name could not be returned.

Reimplemented in XrdLinkXeq.

int XrdLink::Close ( bool  defer = false  ) 

Close the link.

Parameters:
defer If 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.

Reimplemented in XrdLinkXeq.

void XrdLink::DoIt (  )  [protected, virtual]

Implements XrdJob.

Reimplemented in XrdLinkXeq.

void XrdLink::Enable (  ) 

Enable the link to field interrupts.

int XrdLink::FDnum (  ) 

Get the associated file descriptor.

Returns:
The file descriptor number.
static XrdLink* XrdLink::Find ( int &  curr,
XrdLinkMatch who = 0 
) [static]

Find the next link matching certain attributes.

Parameters:
curr Is 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.
who If 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.

Reimplemented in XrdLinkCtl.

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

Get I/O statistics.

Parameters:
inbytes The number of bytes read.
outbytes The number of bytes written.
numstall The number of times the link was rescheduled due to unavailability.
numtardy The number of times the link was delayed due to unavailability.
Returns:
The link's reference count. The parameters will hold the indicated statistic.

Reimplemented in XrdLinkXeq.

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

Find the next client name matching certain attributes.

Parameters:
cur Is 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.
bname Pointer to a buffer where the name is to be returned.
blen The length of the buffer.
who If 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.

Reimplemented in XrdLinkCtl, and XrdLinkXeq.

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.

Reimplemented in XrdLinkXeq.

XrdProtocol* XrdLink::getProtocol (  ) 

Obtain current protocol object pointer.

Reimplemented in XrdLinkXeq.

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.

bool XrdLink::hasTLS (  )  const [inline]

Determine if this link is using TLS.

Parameters:
vprot if not nil, the TLS protocol version number if returned. If the link is not using TLS the version is a null string.
Returns:
true this link is using TLS.
false this link not using TLS.

References isTLS.

void XrdLink::Hold ( bool  lk  ) 

Lock or unlock the mutex used for control operations.

Parameters:
lk When true, a lock is obtained. Otherwise it is released. The caller is responsible for consistency.
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.

unsigned int XrdLink::Inst (  )  const [inline]

Obtain the link's instance number.

Returns:
The link's instance number.

References Instance.

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.
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:
inst the expected instance number.
Returns:
true the link matches the instance number. false the link differs the instance number.
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.

Reimplemented in XrdLinkXeq.

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.

Reimplemented in XrdLinkXeq.

Referenced by XrdCmsNode::isNode().

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

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

Parameters:
buff pointer to buffer to hold data.
blen length of buffer.
timeout milliseconds 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.

Reimplemented in XrdLinkXeq.

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:
buff pointer to buffer to hold data.
blen length of buffer (implies the actual bytes wanted).
timeout milliseconds 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.

Reimplemented in XrdLinkXeq.

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:
buff pointer to buffer to hold data.
blen length of buffer (implies the maximum bytes wanted).
Returns:
>=0 buffer holds data equal to the returned value. < 0 an error occurred.

Reimplemented in XrdLinkXeq.

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:
buff pointer to buffer to hold data.
blen length of buffer (implies the maximum bytes wanted).
timeout milliseconds 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.

Reimplemented in XrdLinkXeq.

bool XrdLink::Register ( const char *  hName  ) 

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

Parameters:
hName -> 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.

Reimplemented in XrdLinkXeq.

void XrdLink::ResetLink (  )  [protected]
int XrdLink::Send ( const sfVec sdP,
int  sdn 
)

Reimplemented in XrdLinkXeq.

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:
iov pointer to the message vector.
iocnt number of iov elements in the vector.
bytes the sum of the sizes in the vector.
Returns:
>=0 number of bytes sent. < 0 an error occurred.

Reimplemented in XrdLinkXeq.

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:
buff pointer to buffer to send.
blen length of buffer.
Returns:
>=0 number of bytes sent. < 0 an error or occurred.

Reimplemented in XrdLinkXeq.

Referenced by XrdCmsNode::Send().

void XrdLink::Serialize (  ) 

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

int XrdLink::setEtext ( const char *  text  ) 

Set an error indication on he link.

Parameters:
text a message describing the error.
Returns:
=0 message set, the link is considered in error. -1 the message pointer was nil.
void XrdLink::setID ( const char *  userid,
int  procid 
)

Set the client's link identity.

Parameters:
userid pointer to the client's username.
procid the client's process id (i.e. pid).

Reimplemented in XrdLinkXeq.

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

Set the client's location.

Parameters:
loc reference to the location information.

Reimplemented in XrdLinkXeq.

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.

Reimplemented in XrdLinkXeq.

void XrdLink::setProtName ( const char *  name  ) 

Set the link's protocol name.

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

Reimplemented in XrdLinkXeq.

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

Set the link's protocol.

Parameters:
pp pointer to the protocol object.
runit if true, starts running the protocol.
push if true, pushes current protocol to be the alternate one.
Returns:
pointer to the previous protocol (may be nil).
void XrdLink::setRef ( int  cnt  ) 

Set the link's parallel usage count.

Parameters:
cnt should be 1 to increased the count and -1 to decrease it.
bool XrdLink::setTLS ( bool  enable,
XrdTlsContext ctx = 0 
)

Enable or disable TLS on the link.

Parameters:
enable if 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.
ctx The context to use when enabling TLS. When nil, the default context is used.
Returns:
True if successful, false otherwise.

Reimplemented in XrdLinkXeq.

void XrdLink::Shutdown ( bool  getLock  ) 

Shutdown the link but otherwise keep it intact.

Parameters:
getlock if true, the operation is performed under a lock.

Reimplemented in XrdLinkXeq.

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

Obtain link statistics.

Parameters:
buff pointer to the buffer for the xml statistics.
blen length of the buffer.
do_sync if 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.

Reimplemented in XrdLinkXeq.

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

Add all local statistics to the global counters.

Parameters:
ctime if not nil, return the total connect time in seconds.

Reimplemented in XrdLinkXeq.

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

Terminate a connection.

Parameters:
owner pointer 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.
fdnum the file descriptor number of the link to be terminated.
inst the 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.
time_t XrdLink::timeCon (  )  const

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

int XrdLink::UseCnt (  )  const

Return link's reference count.

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;

Reimplemented in XrdLinkXeq.

int XrdLink::Wait4Data ( int  timeout  )  [protected]

Member Data Documentation

char* XrdLink::HostName [protected]

Referenced by Host().

char* XrdLink::ID

Pointer to the client's link identity.

unsigned int XrdLink::Instance [protected]

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

bool XrdLink::isBridged [protected]

Referenced by hasBridge().

bool XrdLink::isTLS [protected]

Referenced by hasTLS().

void* XrdLink::rsvd1[3] [protected]
char XrdLink::rsvd2[2] [protected]
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:
sdP pointer to the sendfile vector.
sdn number 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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 7 Jul 2020 for xrootd by  doxygen 1.6.1