34 #include <sys/param.h>
35 #include <sys/types.h>
58 #define Duplicate(x,y) if (y) free(y); y = strdup(x)
60 #define TS_String(x,m) if (!strcmp(x,var)) {Duplicate(val,m); return 0;}
62 #define TS_Xeq(x,m) if (!strcmp(x,var)) return m(&eDest, Config);
83 if (LocalRoot) free(LocalRoot);
84 if (RemotRoot) free(RemotRoot);
85 if (N2NLib) free(N2NLib);
86 if (N2NParms) free(N2NParms);
87 if (cPath) free(cPath);
88 if (cParm) free(cParm);
89 if (mPath) free(mPath);
90 if (mParm) free(mParm);
110 const char *theIname =
"*client anon@localhost";
113 int cfgFD, retc, pfxlen = strlen(pfx);
137 if (hush) logP->Capture(&tFifo);
141 while((var =
Config.GetMyFirstWord()))
142 {
if (!strncmp(var, pfx, pfxlen) && !Parse(var+pfxlen,
Config,
eDest))
143 {
Config.Echo(); aOK =
false;}
150 if ((!aOK || warn) && tFifo.
first) WarnConfig(
eDest, tFifo.
first, !aOK);
156 if ((retc =
Config.LastError()))
178 if (!ep)
return false;
193 if (!N2NLib && !LocalRoot)
202 {
const char *txt = (
xLfn2Pfn ?
"-lfncache option" :
"directive");
203 eDest.
Say(
"Config warning: ignoring namelib ", txt,
204 "; caching not in effect!");
210 return (
theN2N = n2nLoader.Load(N2NLib, *myVersion)) != 0;
228 if (cPath && !ConfigCache(
eDest))
232 WarnPlugin(
eDest, tFifo.
first,
"cachelib", cPath);
241 WarnPlugin(
eDest, tFifo.
first,
"ccmlib", mPath);
250 if (!ConfigN2N(
eDest))
254 if (N2NLib) WarnPlugin(
eDest,tFifo.
first,
"namelib",N2NLib);
255 else WarnPlugin(
eDest,tFifo.
first,
"name2name for",LocalRoot);
301 eDest.
Say(
"Config warning: ignoring unknown directive '",var,
"'.");
332 long long llVal, cSize=-1, m2Cache=-1, pSize=-1, minPg = -1;
334 char *val, *sfSfx = 0, sfVal =
'0', lgVal =
'0', dbVal =
'0', rwVal =
'0';
335 char eBuff[2048], pBuff[1024], *eP;
336 struct sztab {
const char *Key;
long long *Val;} szopts[] =
337 {{
"max2cache", &m2Cache},
338 {
"minpages", &minPg},
339 {
"pagesize", &pSize},
342 int i, numopts =
sizeof(szopts)/
sizeof(
struct sztab);
350 if (!(val =
Config.GetWord()))
351 {
mCache = strdup(
"mode=s&optwr=0");
return true;}
354 do{
for (i = 0; i < numopts; i++)
if (!strcmp(szopts[i].Key, val))
break;
357 {
if (!(val =
Config.GetWord())) ivN = szopts[i].Key;
360 else *(szopts[i].Val) = llVal;
362 if (!strcmp(
"debug", val))
363 {
if (!(val =
Config.GetWord())
364 || ((*val < '0' || *val >
'3') && !*(val+1))) ivN =
"debug";
367 else if (!strcmp(
"logstats", val)) lgVal =
'1';
368 else if (!strcmp(
"preread", val))
370 if (*pBuff ==
'?')
return false;
373 else if (!strcmp(
"r/w", val)) rwVal =
'1';
374 else if (!strcmp(
"sfiles", val))
375 {
if (sfSfx) {free(sfSfx); sfSfx = 0;}
376 if (!(val =
Config.GetWord())) ivN =
"sfiles";
377 else if (!strcmp(
"on", val)) sfVal =
'1';
378 else if (!strcmp(
"off", val)) sfVal =
'0';
379 else if (*val ==
'.' && strlen(val) < 16) sfSfx = strdup(val);
382 else {Eroute->
Emsg(
"Config",
"invalid cache keyword -", val);
388 {
if (!val) Eroute->
Emsg(
"Config",
"cache", ivN,
"value not specified.");
389 else Eroute->
Emsg(
"Config", val,
"is invalid for cache", ivN);
392 }
while ((val =
Config.GetWord()));
396 strcpy(eBuff,
"mode=s&maxfiles=16384"); eP = eBuff + strlen(eBuff);
397 if (cSize > 0) eP += sprintf(eP,
"&cachesz=%lld", cSize);
398 if (dbVal !=
'0') eP += sprintf(eP,
"&debug=%c", dbVal);
399 if (m2Cache > 0) eP += sprintf(eP,
"&max2cache=%lld", m2Cache);
401 {
if (minPg > 32767) minPg = 32767;
402 eP += sprintf(eP,
"&minpages=%lld", minPg);
404 if (pSize > 0) eP += sprintf(eP,
"&pagesz=%lld", pSize);
405 if (lgVal !=
'0') strcat(eP,
"&optlg=1");
406 if (sfVal !=
'0' || sfSfx)
407 {
if (!sfSfx) strcat(eP,
"&optsf=1");
408 else {strcat(eP,
"&optsf="); strcat(eBuff, sfSfx); free(sfSfx);}
410 if (rwVal !=
'0') strcat(eP,
"&optwr=1");
411 if (*pBuff) strcat(eP, pBuff);
429 long long minr = 0, maxv = 0x7fffffff, recb = 50*1024*1024;
430 int minp = 1, perf = 90, Spec = 0;
436 if ((val =
Config.GetWord()) && isdigit(*val))
437 {
if (
XrdOuca2x::a2i(*Eroute,
"preread pages",val,&minp,0,32767))
return 0;
438 if ((val =
Config.GetWord()) && isdigit(*val))
445 if (val && !strcmp(
"perf", val))
446 {
if (!(val =
Config.GetWord()))
447 {Eroute->
Emsg(
"Config",
"cache",
"preread perf value not specified.");
451 if ((val =
Config.GetWord()) && isdigit(*val))
461 if (!Spec) strcpy(pBuff,
"&optpr=1&aprminp=1");
462 else sprintf(pBuff,
"&optpr=1&aprtrig=%lld&aprminp=%d&aprcalc=%lld"
463 "&aprperf=%d",minr,minp,recb,perf);
488 if (!(val =
Config.GetWord()) || !val[0])
489 {Eroute->
Emsg(
"Config",
"ciosync parameter not specified");
return false;}
493 if (
XrdOuca2x::a2i(*Eroute,
"ciosync interval",val,&tsec,10))
return false;
497 if (!(val =
Config.GetWord()) || !val[0])
498 {Eroute->
Emsg(
"Config",
"max time not specified");
return false;}
502 if (
XrdOuca2x::a2i(*Eroute,
"ciosync max time",val,&mtry,2))
return false;
527 char *val, parms[2048];
531 if (!(val =
Config.GetWord()) || !val[0])
532 {Eroute->
Emsg(
"Config",
"cachelib not specified");
return false;}
536 if (cPath) free(cPath);
537 if (!strcmp(val,
"libXrdFileCache.so") || !strcmp(val,
"libXrdFileCache-4.so"))
538 {Eroute->
Say(
"Config warning: 'libXrdFileCache' has been replaced by "
539 "'libXrdPfc'; for future compatibility specify 'default' instead!");
540 cPath = strdup(
"libXrdPfc.so");
542 cPath = (strcmp(val,
"default") ? strdup(val) : strdup(
"libXrdPfc.so"));
547 if (!
Config.GetRest(parms,
sizeof(parms)))
548 {Eroute->
Emsg(
"Config",
"cachelib parameters too long");
return false;}
549 if (cParm) free(cParm);
550 cParm = (*parms ? strdup(parms) : 0);
573 char *val, parms[2048];
577 if (!(val =
Config.GetWord()) || !val[0])
578 {Eroute->
Emsg(
"Config",
"ccmlib not specified");
return false;}
582 if (mPath) free(mPath);
587 if (!
Config.GetRest(parms,
sizeof(parms)))
588 {Eroute->
Emsg(
"Config",
"ccmlib parameters too long");
return false;}
589 if (mParm) free(mParm);
590 mParm = (*parms ? strdup(parms) : 0);
617 if (!(val =
Config.GetWord()) || !val[0])
618 {Eroute->
Emsg(
"Config",
"inetmode value not specified");
return false;}
622 if (!strcmp(val,
"v4"))
useV4 =
true;
623 else if (!strcmp(val,
"v6"))
useV4 =
false;
624 else {Eroute->
Emsg(
"Config",
"invalid inetmode value -", val);
return false;}
648 char *val, parms[1024];
649 bool l2p =
false, p2l =
false, p2lsrc =
false, p2lsgi =
false;
653 while((val =
Config.GetWord()) && val[0])
654 {
if (!strcmp(val,
"-lfn2pfn")) l2p =
true;
655 else if (!strcmp(val,
"-lfncache")) p2l =
true;
656 else if (!strcmp(val,
"-lfncachesrc")) p2l = p2lsrc =
true;
657 else if (!strcmp(val,
"-lfncachesrc+")) p2l = p2lsgi =
true;
661 if (!l2p && !p2l) l2p =
true;
671 {Eroute->
Emsg(
"Config",
"namelib not specified");
return false;}
676 if (N2NLib) free(N2NLib);
677 N2NLib = strdup(val);
681 if (!
Config.GetRest(parms,
sizeof(parms)))
682 {Eroute->
Emsg(
"Config",
"namelib parameters too long");
return false;}
683 if (N2NParms) free(N2NParms);
684 N2NParms = (*parms ? strdup(parms) : 0);
704 char kword[256], *val;
706 static struct sopts {
const char *Sopt;
const char *Copt;
int isT;} Sopts[] =
708 {
"ConnectTimeout",
"ConnectionWindow",1},
709 {
"ConnectionRetry",
"ConnectionRetry",1},
710 {
"DataServerTTL",
"DataServerTTL",1},
711 {
"DataServerConn_ttl",
"DataServerTTL",1},
712 {
"DebugLevel",
"*",0},
713 {
"DebugMask",
"*",0},
714 {
"DirlistAll",
"DirlistAll",0},
715 {
"DataServerTTL",
"DataServerTTL",1},
716 {
"LBServerConn_ttl",
"LoadBalancerTTL",1},
717 {
"LoadBalancerTTL",
"LoadBalancerTTL",1},
718 {
"ParallelEvtLoop",
"ParallelEvtLoop",0},
719 {
"ParStreamsPerPhyConn",
"SubStreamsPerChannel",0},
720 {
"ReadAheadSize", 0,0},
721 {
"ReadAheadStrategy", 0,0},
722 {
"ReadCacheBlkRemPolicy", 0,0},
723 {
"ReadCacheSize", 0,0},
724 {
"ReadTrimBlockSize", 0,0},
725 {
"ReconnectWait",
"StreamErrorWindow",1},
726 {
"RedirCntTimeout",
"!use RedirectLimit instead.",0},
727 {
"RedirectLimit",
"RedirectLimit",0},
728 {
"RedirectorConn_ttl",
"LoadBalancerTTL",1},
729 {
"RemoveUsedCacheBlocks", 0,0},
730 {
"RequestTimeout",
"RequestTimeout",1},
731 {
"StreamTimeout",
"StreamTimeout",1},
732 {
"TransactionTimeout",
"",1},
733 {
"WorkerThreads",
"WorkerThreads",0}
735 int i, numopts =
sizeof(Sopts)/
sizeof(
struct sopts);
737 if (!(val =
Config.GetWord()))
738 {Eroute->
Emsg(
"Config",
"setopt keyword not specified");
return false;}
739 strlcpy(kword, val,
sizeof(kword));
740 if (!(val =
Config.GetWord()))
741 {Eroute->
Emsg(
"Config",
"setopt", kword,
"value not specified");
745 for (i = 0; i < numopts; i++)
746 if (!strcmp(Sopts[i].Sopt, kword))
747 {
if (!Sopts[i].Copt || *(Sopts[i].Copt) ==
'!')
748 {Eroute->
Emsg(
"Config", kword,
"no longer supported;",
749 (Sopts[i].Copt ? Sopts[i].Copt+1 :
"ignored"));
750 }
else if (*(Sopts[i].Copt))
751 {noGo = (Sopts[i].isT
754 if (noGo)
return false;
755 if (*(Sopts[i].Copt) ==
'*')
debugLvl = kval;
761 Eroute->
Say(
"Config warning: ignoring unknown setopt '",kword,
"'.");
794 static struct traceopts {
const char *opname;
int opval;} tropts[] =
800 int i, trval = 0, numopts =
sizeof(tropts)/
sizeof(
struct traceopts);
802 if (!(val =
Config.GetWord()))
803 {Eroute->
Emsg(
"Config",
"trace option not specified");
return false;}
805 {
if (!strcmp(val,
"off")) trval = 0;
806 else {
for (i = 0; i < numopts; i++)
807 {
if (!strcmp(val, tropts[i].opname))
808 {trval |= tropts[i].opval;
813 {Eroute->
Say(
"Config warning: ignoring invalid trace option '",val,
"'.");
831 if (LocalRoot) free(LocalRoot);
832 if (!lroot) LocalRoot = 0;
833 {LocalRoot = strdup(lroot);
839 if (RemotRoot) free(RemotRoot);
840 RemotRoot = (rroot ? strdup(rroot) : 0);
854 eDest.
Say(
"Config problem: ",(fatal ?
"fatal ":0),
"errors in config file '",
871 const char *txt1,
const char *txt2)
878 eDest.
Say(
"Config problem: unable to load ", txt1,
" ", txt2,
879 "'; details below.\n");
static XrdSysError eDest(0,"crypto_")
bool(* XrdOucCacheCMInit_t)(XrdPosixCache &Cache, XrdSysLogger *Logger, const char *Config, const char *Parms, XrdOucEnv *envP)
XrdOucCache *(* XrdOucCache_t)(XrdSysLogger *Logger, const char *Config, const char *Parms, XrdOucEnv *envP)
int open(const char *path, int oflag,...)
static int Export(const char *Var, const char *Val)
bool ParseINet(XrdSysError *Eroute, XrdOucStream &Config)
bool ClientConfig(const char *pfx, bool hush=false)
bool ParseCio(XrdSysError *Eroute, XrdOucStream &Config)
void SetRoot(const char *lroot, const char *oroot=0)
bool ParseMLib(XrdSysError *Eroute, XrdOucStream &Config)
bool ParseCache(XrdSysError *Eroute, XrdOucStream &Config)
XrdOucCacheCMInit_t initCCM
bool ParseCLib(XrdSysError *Eroute, XrdOucStream &Config)
bool ConfigSetup(XrdSysError &eDest, bool hush=false)
bool ParseNLib(XrdSysError *Eroute, XrdOucStream &Config)
bool ParseTrace(XrdSysError *Eroute, XrdOucStream &Config)
bool ParseSet(XrdSysError *Eroute, XrdOucStream &Config)
static int a2i(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
static int a2sz(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
static int a2tm(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
XrdSysLogger * logger(XrdSysLogger *lp=0)
void Capture(XrdOucTListFIFO *tFIFO)