Skip to content

Commit

Permalink
Further backward compatability changes for supervisor redirect lists.
Browse files Browse the repository at this point in the history
Use hostname in list unless cms.sched tryhname 0 specifed.
Add option to netaddr.format to return IPv4 address (no abi change).
  • Loading branch information
abh3 authored and ljanyst committed Apr 16, 2015
1 parent 225492e commit aa70936
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/XrdCms/XrdCmsCluster.cc
Expand Up @@ -1803,11 +1803,14 @@ void XrdCmsCluster::setAltMan(int snum, XrdLink *lp, int port)
if (!port || (port > 0x0000ffff)) port = Config.PortTCP;
memset(ap, int(' '), AltSize);

// First tr to use the hostname:port which may be too large (unlikely). Else
// Insert the ip address of this node into the list of nodes. We made sure that
// the size of he buffer was big enough so no need to check for overflow.
//
altAddr.Port(port);
i = altAddr.Format(ap, AltSize, XrdNetAddr::fmtAddr);
if (Config.DoHnTry) i = altAddr.Format(ap, AltSize, XrdNetAddr::fmtName);
else i = 0;
if (!i) i=altAddr.Format(ap,AltSize,XrdNetAddr::fmtAddr,XrdNetAddr::prefipv4);
ap[i] = ' ';

// Compute new fence
Expand Down
4 changes: 2 additions & 2 deletions src/XrdCms/XrdCmsCluster.hh
Expand Up @@ -218,9 +218,9 @@ void setAltMan(int snum, XrdLink *lp, int port);
int Unreachable(XrdCmsSelect &Sel, bool none);
int Unuseable(XrdCmsSelect &Sel);

// Number of IP:Port characters per entry
// Number of <host>:Port characters per entry was INET6_ADDRSTRLEN+10
//
static const int AltSize = INET6_ADDRSTRLEN+10;
static const int AltSize = 254; // We may revert to IP address

XrdSysMutex XXMutex; // Protects cluster summary state variables
XrdSysMutex STMutex; // Protects all node information variables
Expand Down
10 changes: 8 additions & 2 deletions src/XrdCms/XrdCmsConfig.cc
Expand Up @@ -671,6 +671,7 @@ void XrdCmsConfig::ConfigDefaults(void)
AskPing = 60; // Every 1 minute
PingTick = 0;
DoMWChk = 1;
DoHnTry = 1;
MaxDelay = -1;
LogPerf = 10; // Every 10 usage requests
DiskMin = 10240; // 10GB*1024 (Min partition space) in MB
Expand Down Expand Up @@ -2485,7 +2486,7 @@ int XrdCmsConfig::xrole(XrdSysError *eDest, XrdOucStream &CFile)
int XrdCmsConfig::xsched(XrdSysError *eDest, XrdOucStream &CFile)
{
char *val;
int i, ppp;
int i, ppp, V_hntry = -1;
static struct schedopts {const char *opname; int maxv; int *oploc;}
scopts[] =
{
Expand All @@ -2499,7 +2500,8 @@ int XrdCmsConfig::xsched(XrdSysError *eDest, XrdOucStream &CFile)
{"pag", 100, &P_pag},
{"space", 100, &P_dsk},
{"maxload", 100, &MaxLoad},
{"refreset", -1, &RefReset}
{"refreset", -1, &RefReset},
{"tryhname", 1, &V_hntry}
};
int numopts = sizeof(scopts)/sizeof(struct schedopts);

Expand Down Expand Up @@ -2528,6 +2530,10 @@ int XrdCmsConfig::xsched(XrdSysError *eDest, XrdOucStream &CFile)
val = CFile.GetWord();
}

// Handle non-int settings
//
if (V_hntry >= 0) DoHnTry = static_cast<char>(V_hntry);

return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion src/XrdCms/XrdCmsConfig.hh
Expand Up @@ -103,7 +103,8 @@ int P_mem; // % MEM Capacity in load factor
int P_pag; // % PAG Capacity in load factor

char DoMWChk; // When true (default) perform multiple write check
char Rsvd[3]; // Reserved for alignment
char DoHnTry; // When true (default) use hostnames for try redirs
char Rsvd[2]; // Reserved for alignment

int DiskMin; // Minimum MB needed of space in a partition
int DiskHWM; // Minimum MB needed of space to requalify
Expand Down
8 changes: 5 additions & 3 deletions src/XrdNet/XrdNetAddrInfo.cc
Expand Up @@ -113,9 +113,11 @@ int XrdNetAddrInfo::Format(char *bAddr, int bLen, fmtUse theFmt, int fmtOpts)
//
if (IP.Addr.sa_family == AF_INET6)
{if (bLen < (INET6_ADDRSTRLEN+2)) return QFill(bAddr, bLen);
if (fmtOpts & old6Map4 && IN6_IS_ADDR_V4MAPPED(&IP.v6.sin6_addr))
{if (ipRaw) {strcpy(bAddr, "::"); n = 2;}
else {strcpy(bAddr, "[::"); n = 3; addBrak=1;}
if (fmtOpts & (old6Map4 | prefipv4)
&& IN6_IS_ADDR_V4MAPPED(&IP.v6.sin6_addr))
{ if (fmtOpts & prefipv4) {n = 0; pFmt = ":%d";}
else if (ipRaw) {strcpy(bAddr, "::"); n = 2;}
else {strcpy(bAddr, "[::"); n = 3; addBrak=1;}
if (!inet_ntop(AF_INET, &IP.v6.sin6_addr.s6_addr32[3],
bAddr+n, bLen-n)) return QFill(bAddr, bLen);
} else {
Expand Down
1 change: 1 addition & 0 deletions src/XrdNet/XrdNetAddrInfo.hh
Expand Up @@ -94,6 +94,7 @@ enum fmtUse {fmtAuto=0, //!< Hostname if already resolved o/w use fmtAddr
static const int noPort = 0x0000001; //!< Do not add port number
static const int noPortRaw = 0x0000002; //!< Use raw address format (no port)
static const int old6Map4 = 0x0000004; //!< Use deprecated IPV6 mapped format
static const int prefipv4 = 0x0000008; //!< Use if mapped IPV4 actual format

int Format(char *bAddr, int bLen, fmtUse fmtType=fmtAuto, int fmtOpts=0);

Expand Down

0 comments on commit aa70936

Please sign in to comment.