34 #include <sys/types.h>
37 #if defined(__linux__) || defined(__GNU__)
38 #include <netinet/tcp.h>
39 #if !defined(TCP_CORK)
47 #if !defined(__FreeBSD__)
48 #include <sys/sendfile.h>
50 #include <sys/types.h>
51 #include <sys/socket.h>
68 #define TRACE_IDENT ID
74 #define ETIME ETIMEDOUT
92 #if defined(HAVE_SENDFILE)
100 const unsigned char KillMax = 60;
101 const unsigned char KillMsk = 0x7f;
102 const unsigned char KillXwt = 0x80;
104 const char *TraceID =
"Link";
205 int &numstall,
int &numtardy)
277 else return linkXQ.
Peek (Buff, Blen, timeout);
295 else return linkXQ.
Recv (Buff, Blen, timeout);
343 if (!bytes)
for (
int i = 0; i < iocnt; i++) bytes +=
iov[i].iov_len;
358 {
Log.
Emsg(
"Link", E2BIG,
"send file to",
ID);
383 TRACEI(
DEBUG,
"Waiting for link serialization; use="
465 Log.
Emsg(
"Link",
"Zero use count for",
ID);
470 TRACEI(CONN,
"setRef posted link");
478 Log.
Emsg(
"Link",
"Negative use count for",
ID);
491 if (
isTLS == enable)
return true;
529 if (lp ==
this)
return 0;
531 if (!(cp = index(
ID,
':')) || strncmp(lp->
ID,
ID, cp-
ID)
550 int wTime, killTries;
552 if (killTries > KillMax)
return -
ETIME;
565 return (wTime > 60 ? 60: wTime);
577 snprintf(buff,
sizeof(buff),
"ended by %s", owner);
578 buff[
sizeof(buff)-1] =
'\0';
599 TRACEI(
DEBUG,
"Terminate " << (wTime <= 0 ?
"complete ":
"timeout ") <<wTime);
635 do {retc = poll(&polltab, 1, timeout);}
while(retc < 0 && errno == EINTR);
637 {
if (retc == 0)
return 0;
644 if (!(polltab.revents & (POLLIN|POLLRDNORM)))
static XrdLink * fd2link(int fd)
static XrdLink * Find(int &curr, XrdLinkMatch *who=0)
static short killWait
Link destruction control constants.
static int getName(int &curr, char *bname, int blen, XrdLinkMatch *who=0)
XrdSysSemaphore IOSemaphore
int TLS_Send(const char *Buff, int Blen)
int TLS_Peek(char *Buff, int Blen, int timeout)
int Client(char *buff, int blen)
XrdTlsPeerCerts * getPeerCerts()
const char * Name() const
int Close(bool defer=false)
int TLS_Recv(char *Buff, int Blen)
XrdProtocol * setProtocol(XrdProtocol *pp, bool push)
void Shutdown(bool getLock)
int Peek(char *buff, int blen, int timeout=-1)
static int Stats(char *buff, int blen, bool do_sync=false)
void setID(const char *userid, int procid)
XrdNetAddrInfo * AddrInfo()
int Recv(char *buff, int blen)
int TLS_RecvAll(char *Buff, int Blen, int timeout)
const XrdNetAddr * NetAddr() const
int Send(const char *buff, int blen)
void setLocation(XrdNetAddrInfo::LocInfo &loc)
int RecvAll(char *buff, int blen, int timeout=-1)
bool Register(const char *hName)
void setProtName(const char *name)
void syncStats(int *ctime=0)
XrdProtocol * getProtocol()
bool setTLS(bool enable, XrdTlsContext *ctx=0)
int getIOStats(long long &inbytes, long long &outbytes, int &numstall, int &numtardy)
XrdProtocol * setProtocol(XrdProtocol *pp, bool runit=false, bool push=false)
void Serialize()
Wait for all outstanding requests to be completed on the link.
int Wait4Data(int timeout)
static XrdLink * Find(int &curr, XrdLinkMatch *who=0)
int setEtext(const char *text)
bool isInstance(unsigned int inst) const
bool setTLS(bool enable, XrdTlsContext *ctx=0)
Enable or disable TLS on the link.
int Peek(char *buff, int blen, int timeout=-1)
int Recv(char *buff, int blen)
void syncStats(int *ctime=0)
const char * Host() const
static int getName(int &curr, char *bname, int blen, XrdLinkMatch *who=0)
time_t timeCon() const
Return the time the link was made active (i.e. time of connection).
int Close(bool defer=false)
int Terminate(const char *owner, int fdnum, unsigned int inst)
void setID(const char *userid, int procid)
int UseCnt() const
Return link's reference count.
const XrdNetAddr * NetAddr() const
int RecvAll(char *buff, int blen, int timeout=-1)
void Enable()
Enable the link to field interrupts.
XrdTlsPeerCerts * getPeerCerts()
XrdNetAddrInfo * AddrInfo()
char * ID
Pointer to the client's link identity.
int Send(const char *buff, int blen)
bool Register(const char *hName)
void armBridge()
Mark this link as an in-memory communications bridge (internal use only).
void setProtName(const char *name)
void setLocation(XrdNetAddrInfo::LocInfo &loc)
int getIOStats(long long &inbytes, long long &outbytes, int &numstall, int &numtardy)
XrdProtocol * getProtocol()
Obtain current protocol object pointer.
int Client(char *buff, int blen)
const char * Name() const
void Shutdown(bool getLock)
static int Stats(char *buff, int blen, bool do_sync=0)
virtual int Enable(XrdPollInfo &pInfo)=0
static char * Poll2Text(short events)
virtual void Disable(XrdPollInfo &pInfo, const char *etxt=0)=0
static int Attach(XrdPollInfo &pInfo)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)