xrootd
Loading...
Searching...
No Matches
XrdLinkCtl.hh
Go to the documentation of this file.
1#ifndef __XRD_LINKCTL_H__
2#define __XRD_LINKCTL_H__
3/******************************************************************************/
4/* */
5/* X r d L i n k C t l . h h */
6/* */
7/* (c) 2018 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* Produced by Andrew Hanushevsky for Stanford University under contract */
9/* DE-AC02-76-SFO0515 with the Department of Energy */
10/* */
11/* This file is part of the XRootD software suite. */
12/* */
13/* XRootD is free software: you can redistribute it and/or modify it under */
14/* the terms of the GNU Lesser General Public License as published by the */
15/* Free Software Foundation, either version 3 of the License, or (at your */
16/* option) any later version. */
17/* */
18/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21/* License for more details. */
22/* */
23/* You should have received a copy of the GNU Lesser General Public License */
24/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26/* */
27/* The copyright holder's institutional names and contributor's names may not */
28/* be used to endorse or promote products derived from this software without */
29/* specific prior written permission of the institution or contributor. */
30/******************************************************************************/
31
32#include "Xrd/XrdLinkXeq.hh"
33
35
36/******************************************************************************/
37/* C l a s s D e f i n i t i o n */
38/******************************************************************************/
39
40class XrdLinkMatch;
41
42class XrdLinkCtl : protected XrdLinkXeq
43{
44public:
45
46//-----------------------------------------------------------------------------
56//-----------------------------------------------------------------------------
57
58#define XRDLINK_RDLOCK 0x0001
59#define XRDLINK_NOCLOSE 0x0002
60
61static XrdLink *Alloc(XrdNetAddr &peer, int opts=0);
62
63//-----------------------------------------------------------------------------
70//-----------------------------------------------------------------------------
71
72static XrdLink *fd2link(int fd)
73 {if (fd < 0) fd = -fd;
74 return (fd <= LTLast && LinkBat[fd] ? LinkTab[fd] : 0);
75 }
76
77//-----------------------------------------------------------------------------
85//-----------------------------------------------------------------------------
86
87static XrdLink *fd2link(int fd, unsigned int inst)
88 {if (fd < 0) fd = -fd;
89 if (fd <= LTLast && LinkBat[fd] && LinkTab[fd]
90 && LinkTab[fd]->Instance == inst) return LinkTab[fd];
91 return (XrdLink *)0;
92 }
93
94//-----------------------------------------------------------------------------
101//-----------------------------------------------------------------------------
102
104 {if (fd < 0) fd = -fd;
105 if (fd <= LTLast && LinkBat[fd])
106 return &(LinkTab[fd]->PollInfo);
107 return 0;
108 }
109
110//-----------------------------------------------------------------------------
124//-----------------------------------------------------------------------------
125
126static XrdLink *Find(int &curr, XrdLinkMatch *who=0);
127
128//-----------------------------------------------------------------------------
142//-----------------------------------------------------------------------------
143
144static int getName(int &curr, char *bname, int blen, XrdLinkMatch *who=0);
145
146//-----------------------------------------------------------------------------
148//-----------------------------------------------------------------------------
149
150static void idleScan();
151
152//-----------------------------------------------------------------------------
158//-----------------------------------------------------------------------------
159
160static void setKWT(int wkSec, int kwSec);
161
162//-----------------------------------------------------------------------------
170//-----------------------------------------------------------------------------
171
172static int Setup(int maxfds, int idlewt);
173
174//-----------------------------------------------------------------------------
176//-----------------------------------------------------------------------------
177
178static void SyncAll();
179
180//-----------------------------------------------------------------------------
182//-----------------------------------------------------------------------------
183
184static void Unhook(int fd);
185
186//-----------------------------------------------------------------------------
188//-----------------------------------------------------------------------------
189
190static short killWait; // Kill then wait;
191static short waitKill; // Wait then kill
192
193//-----------------------------------------------------------------------------
195//-----------------------------------------------------------------------------
196
198
199private:
200 ~XrdLinkCtl() {} // Is never deleted!
201
202static XrdSysMutex LTMutex; // For the LinkTab only LTMutex->IOMutex allowed
204static char *LinkBat;
205static unsigned int LinkAlloc;
206static int LTLast;
207static int maxFD;
208static const char *TraceID;
209};
210#endif
Definition XrdLinkCtl.hh:43
static XrdSysMutex LTMutex
Definition XrdLinkCtl.hh:202
static int getName(int &curr, char *bname, int blen, XrdLinkMatch *who=0)
static XrdLink * Find(int &curr, XrdLinkMatch *who=0)
~XrdLinkCtl()
Definition XrdLinkCtl.hh:200
static void Unhook(int fd)
Unhook a link from the active table of links.
static const char * TraceID
Definition XrdLinkCtl.hh:208
static short waitKill
Definition XrdLinkCtl.hh:191
static void setKWT(int wkSec, int kwSec)
static XrdLink * fd2link(int fd)
Definition XrdLinkCtl.hh:72
static int LTLast
Definition XrdLinkCtl.hh:206
static XrdLink * fd2link(int fd, unsigned int inst)
Definition XrdLinkCtl.hh:87
static XrdLink * Alloc(XrdNetAddr &peer, int opts=0)
XrdLinkCtl()
Constructor.
Definition XrdLinkCtl.hh:197
static void SyncAll()
Synchronize statustics for ll links.
static int maxFD
Definition XrdLinkCtl.hh:207
static char * LinkBat
Definition XrdLinkCtl.hh:204
static XrdPollInfo * fd2PollInfo(int fd)
Definition XrdLinkCtl.hh:103
static int Setup(int maxfds, int idlewt)
static short killWait
Link destruction control constants.
Definition XrdLinkCtl.hh:190
static XrdLinkCtl ** LinkTab
Definition XrdLinkCtl.hh:203
static void idleScan()
Look for idle links and close hem down.
static unsigned int LinkAlloc
Definition XrdLinkCtl.hh:205
Definition XrdLinkMatch.hh:35
Definition XrdLinkXeq.hh:53
XrdPollInfo PollInfo
Definition XrdLinkXeq.hh:145
Definition XrdNetAddr.hh:42
Definition XrdPollInfo.hh:37
Definition XrdSysPthread.hh:165