mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 15:30:14 +00:00
Reorder bosserver startup prior to pthreads
The rx calls will take locks when built in pthreaded mode, and must go after rx_Init(). Some other setup would benefit from using time-domain locking and should run before we go multithreaded. In particular, initialize bozo_confdir while single-threaded, as it is otherwise protected by the afsconf internal locking. While here, pass NULL to afsconf_SetCellInfo -- bozo_confdir would always be NULL there, anyway. Change a couple globals into local variables in main; they are just used to defer setup after argument parsing. ReadBozoFile will create worker threads to monitor child processes, so it cannot move up too far. Change when we daemonize, too. Change-Id: If7b6883748919270c9a5a41cd8e6fb724e95aa36 Reviewed-on: http://gerrit.openafs.org/10285 Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Reviewed-by: Derrick Brashear <shadow@your-file-system.com> Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
parent
54eb2485b5
commit
0b1ee8c1c3
@ -762,6 +762,8 @@ main(int argc, char **argv, char **envp)
|
|||||||
char *auditFileName = NULL;
|
char *auditFileName = NULL;
|
||||||
struct rx_securityClass **securityClasses;
|
struct rx_securityClass **securityClasses;
|
||||||
afs_int32 numClasses;
|
afs_int32 numClasses;
|
||||||
|
int DoPeerRPCStats = 0;
|
||||||
|
int DoProcessRPCStats = 0;
|
||||||
#ifndef AFS_NT40_ENV
|
#ifndef AFS_NT40_ENV
|
||||||
int nofork = 0;
|
int nofork = 0;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
@ -866,9 +868,9 @@ main(int argc, char **argv, char **envp)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (strcmp(argv[code], "-enable_peer_stats") == 0) {
|
else if (strcmp(argv[code], "-enable_peer_stats") == 0) {
|
||||||
rx_enablePeerRPCStats();
|
DoPeerRPCStats = 1;
|
||||||
} else if (strcmp(argv[code], "-enable_process_stats") == 0) {
|
} else if (strcmp(argv[code], "-enable_process_stats") == 0) {
|
||||||
rx_enableProcessRPCStats();
|
DoProcessRPCStats = 1;
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[code], "-restricted") == 0) {
|
else if (strcmp(argv[code], "-restricted") == 0) {
|
||||||
bozo_isrestricted = 1;
|
bozo_isrestricted = 1;
|
||||||
@ -943,35 +945,6 @@ main(int argc, char **argv, char **envp)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
code = bnode_Init();
|
|
||||||
if (code) {
|
|
||||||
printf("bosserver: could not init bnode package, code %d\n", code);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
bnode_Register("fs", &fsbnode_ops, 3);
|
|
||||||
bnode_Register("dafs", &dafsbnode_ops, 4);
|
|
||||||
bnode_Register("simple", &ezbnode_ops, 1);
|
|
||||||
bnode_Register("cron", &cronbnode_ops, 2);
|
|
||||||
|
|
||||||
/* create useful dirs */
|
|
||||||
CreateDirs(DoCore);
|
|
||||||
|
|
||||||
/* chdir to AFS log directory */
|
|
||||||
if (DoCore)
|
|
||||||
chdir(DoCore);
|
|
||||||
else
|
|
||||||
chdir(AFSDIR_SERVER_LOGS_DIRPATH);
|
|
||||||
|
|
||||||
/* go into the background and remove our controlling tty, close open
|
|
||||||
file desriptors
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef AFS_NT40_ENV
|
|
||||||
if (!nofork)
|
|
||||||
daemon(1, 0);
|
|
||||||
#endif /* ! AFS_NT40_ENV */
|
|
||||||
|
|
||||||
if ((!DoSyslog)
|
if ((!DoSyslog)
|
||||||
#ifndef AFS_NT40_ENV
|
#ifndef AFS_NT40_ENV
|
||||||
&& ((lstat(AFSDIR_BOZLOG_FILE, &sb) == 0) &&
|
&& ((lstat(AFSDIR_BOZLOG_FILE, &sb) == 0) &&
|
||||||
@ -995,72 +968,27 @@ main(int argc, char **argv, char **envp)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(RLIMIT_CORE) && defined(HAVE_GETRLIMIT)
|
/*
|
||||||
{
|
* go into the background and remove our controlling tty, close open
|
||||||
struct rlimit rlp;
|
* file desriptors
|
||||||
getrlimit(RLIMIT_CORE, &rlp);
|
*/
|
||||||
if (!DoCore)
|
|
||||||
rlp.rlim_cur = 0;
|
#ifndef AFS_NT40_ENV
|
||||||
else
|
if (!nofork)
|
||||||
rlp.rlim_max = rlp.rlim_cur = RLIM_INFINITY;
|
daemon(1, 0);
|
||||||
setrlimit(RLIMIT_CORE, &rlp);
|
#endif /* ! AFS_NT40_ENV */
|
||||||
getrlimit(RLIMIT_CORE, &rlp);
|
|
||||||
bozo_Log("Core limits now %d %d\n",(int)rlp.rlim_cur,(int)rlp.rlim_max);
|
/* create useful dirs */
|
||||||
}
|
CreateDirs(DoCore);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Write current state of directory permissions to log file */
|
/* Write current state of directory permissions to log file */
|
||||||
DirAccessOK();
|
DirAccessOK();
|
||||||
|
|
||||||
if (rxBind) {
|
/* chdir to AFS log directory */
|
||||||
afs_int32 ccode;
|
if (DoCore)
|
||||||
if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
|
chdir(DoCore);
|
||||||
AFSDIR_SERVER_NETINFO_FILEPATH) {
|
else
|
||||||
char reason[1024];
|
chdir(AFSDIR_SERVER_LOGS_DIRPATH);
|
||||||
ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
|
|
||||||
ADDRSPERSITE, reason,
|
|
||||||
AFSDIR_SERVER_NETINFO_FILEPATH,
|
|
||||||
AFSDIR_SERVER_NETRESTRICT_FILEPATH);
|
|
||||||
} else {
|
|
||||||
ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
|
|
||||||
}
|
|
||||||
if (ccode == 1)
|
|
||||||
host = SHostAddrs[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 10; i++) {
|
|
||||||
if (rxBind) {
|
|
||||||
code = rx_InitHost(host, htons(AFSCONF_NANNYPORT));
|
|
||||||
} else {
|
|
||||||
code = rx_Init(htons(AFSCONF_NANNYPORT));
|
|
||||||
}
|
|
||||||
if (code) {
|
|
||||||
bozo_Log("can't initialize rx: code=%d\n", code);
|
|
||||||
sleep(3);
|
|
||||||
} else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i >= 10) {
|
|
||||||
bozo_Log("Bos giving up, can't initialize rx\n");
|
|
||||||
exit(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Disable jumbograms */
|
|
||||||
rx_SetNoJumbo();
|
|
||||||
|
|
||||||
if (rxMaxMTU != -1) {
|
|
||||||
if (rx_SetMaxMTU(rxMaxMTU) != 0) {
|
|
||||||
bozo_Log("bosserver: rxMaxMTU %d is invalid\n", rxMaxMTU);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
code = LWP_CreateProcess(BozoDaemon, BOZO_LWP_STACKSIZE, /* priority */ 1,
|
|
||||||
/* param */ NULL , "bozo-the-clown", &bozo_pid);
|
|
||||||
if (code) {
|
|
||||||
bozo_Log("Failed to create daemon thread\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* try to read the key from the config file */
|
/* try to read the key from the config file */
|
||||||
tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
|
tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
|
||||||
@ -1081,7 +1009,7 @@ main(int argc, char **argv, char **envp)
|
|||||||
}
|
}
|
||||||
memset(tcell.hostAddr, 0, sizeof(tcell.hostAddr)); /* not computed */
|
memset(tcell.hostAddr, 0, sizeof(tcell.hostAddr)); /* not computed */
|
||||||
code =
|
code =
|
||||||
afsconf_SetCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH,
|
afsconf_SetCellInfo(NULL, AFSDIR_SERVER_ETC_DIRPATH,
|
||||||
&tcell);
|
&tcell);
|
||||||
if (code) {
|
if (code) {
|
||||||
bozo_Log
|
bozo_Log
|
||||||
@ -1096,11 +1024,35 @@ main(int argc, char **argv, char **envp)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* opened the cell databse */
|
||||||
|
bozo_confdir = tdir;
|
||||||
|
|
||||||
/* initialize audit user check */
|
code = bnode_Init();
|
||||||
osi_audit_set_user_check(tdir, bozo_IsLocalRealmMatch);
|
if (code) {
|
||||||
|
printf("bosserver: could not init bnode package, code %d\n", code);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
/* read init file, starting up programs */
|
bnode_Register("fs", &fsbnode_ops, 3);
|
||||||
|
bnode_Register("dafs", &dafsbnode_ops, 4);
|
||||||
|
bnode_Register("simple", &ezbnode_ops, 1);
|
||||||
|
bnode_Register("cron", &cronbnode_ops, 2);
|
||||||
|
|
||||||
|
#if defined(RLIMIT_CORE) && defined(HAVE_GETRLIMIT)
|
||||||
|
{
|
||||||
|
struct rlimit rlp;
|
||||||
|
getrlimit(RLIMIT_CORE, &rlp);
|
||||||
|
if (!DoCore)
|
||||||
|
rlp.rlim_cur = 0;
|
||||||
|
else
|
||||||
|
rlp.rlim_max = rlp.rlim_cur = RLIM_INFINITY;
|
||||||
|
setrlimit(RLIMIT_CORE, &rlp);
|
||||||
|
getrlimit(RLIMIT_CORE, &rlp);
|
||||||
|
bozo_Log("Core limits now %d %d\n",(int)rlp.rlim_cur,(int)rlp.rlim_max);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Read init file, starting up programs. Also starts watcher threads. */
|
||||||
if ((code = ReadBozoFile(0))) {
|
if ((code = ReadBozoFile(0))) {
|
||||||
bozo_Log
|
bozo_Log
|
||||||
("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n",
|
("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n",
|
||||||
@ -1108,10 +1060,65 @@ main(int argc, char **argv, char **envp)
|
|||||||
exit(code);
|
exit(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
bozo_CreateRxBindFile(host); /* for local scripts */
|
if (rxBind) {
|
||||||
|
afs_int32 ccode;
|
||||||
|
if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
|
||||||
|
AFSDIR_SERVER_NETINFO_FILEPATH) {
|
||||||
|
char reason[1024];
|
||||||
|
ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
|
||||||
|
ADDRSPERSITE, reason,
|
||||||
|
AFSDIR_SERVER_NETINFO_FILEPATH,
|
||||||
|
AFSDIR_SERVER_NETRESTRICT_FILEPATH);
|
||||||
|
} else {
|
||||||
|
ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
|
||||||
|
}
|
||||||
|
if (ccode == 1)
|
||||||
|
host = SHostAddrs[0];
|
||||||
|
}
|
||||||
|
for (i = 0; i < 10; i++) {
|
||||||
|
if (rxBind) {
|
||||||
|
code = rx_InitHost(host, htons(AFSCONF_NANNYPORT));
|
||||||
|
} else {
|
||||||
|
code = rx_Init(htons(AFSCONF_NANNYPORT));
|
||||||
|
}
|
||||||
|
if (code) {
|
||||||
|
bozo_Log("can't initialize rx: code=%d\n", code);
|
||||||
|
sleep(3);
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i >= 10) {
|
||||||
|
bozo_Log("Bos giving up, can't initialize rx\n");
|
||||||
|
exit(code);
|
||||||
|
}
|
||||||
|
|
||||||
/* opened the cell databse */
|
/* Set some rx config */
|
||||||
bozo_confdir = tdir;
|
if (DoPeerRPCStats)
|
||||||
|
rx_enablePeerRPCStats();
|
||||||
|
if (DoProcessRPCStats)
|
||||||
|
rx_enableProcessRPCStats();
|
||||||
|
|
||||||
|
/* Disable jumbograms */
|
||||||
|
rx_SetNoJumbo();
|
||||||
|
|
||||||
|
if (rxMaxMTU != -1) {
|
||||||
|
if (rx_SetMaxMTU(rxMaxMTU) != 0) {
|
||||||
|
bozo_Log("bosserver: rxMaxMTU %d is invalid\n", rxMaxMTU);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = LWP_CreateProcess(BozoDaemon, BOZO_LWP_STACKSIZE, /* priority */ 1,
|
||||||
|
/* param */ NULL , "bozo-the-clown", &bozo_pid);
|
||||||
|
if (code) {
|
||||||
|
bozo_Log("Failed to create daemon thread\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialize audit user check */
|
||||||
|
osi_audit_set_user_check(bozo_confdir, bozo_IsLocalRealmMatch);
|
||||||
|
|
||||||
|
bozo_CreateRxBindFile(host); /* for local scripts */
|
||||||
|
|
||||||
/* allow super users to manage RX statistics */
|
/* allow super users to manage RX statistics */
|
||||||
rx_SetRxStatUserOk(bozo_rxstat_userok);
|
rx_SetRxStatUserOk(bozo_rxstat_userok);
|
||||||
|
Loading…
Reference in New Issue
Block a user