#include <time.h>
#endif
#include <sys/stat.h>
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+
#include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
#include <lwp.h>
#include <afs/audit.h>
#include <afs/fileutil.h>
#include "bnode.h"
+#ifdef AFS_AIX_ENV
+/* All known versions of AIX lack WCOREDUMP but this works */
+#define WCOREDUMP(x) ((x) & 0x80)
+#endif
+
#define BNODE_LWP_STACKSIZE (16 * 1024)
int bnode_waiting = 0;
#endif
/* Remember the name of the process, if any, that failed last */
-static void RememberProcName(ap)
-register struct bnode_proc *ap; {
+static void RememberProcName(register struct bnode_proc *ap)
+{
register struct bnode *tbnodep;
tbnodep = ap->bnode;
if (tbnodep->lastErrorName) {
free(tbnodep->lastErrorName);
- tbnodep->lastErrorName = (char *) 0;
+ tbnodep->lastErrorName = NULL;
}
if (ap->coreName) {
tbnodep->lastErrorName = (char *) malloc(strlen(ap->coreName)+1);
/* utility for use by BOP_HASCORE functions to determine where a core file might
* be stored.
*/
-bnode_CoreName(abnode, acoreName, abuffer)
-register struct bnode *abnode;
-char *acoreName;
-char *abuffer; {
+int bnode_CoreName(register struct bnode *abnode, char *acoreName,
+ char *abuffer)
+{
strcpy(abuffer, AFSDIR_SERVER_CORELOG_FILEPATH);
if (acoreName) {
strcat(abuffer, acoreName);
}
/* save core file, if any */
-static void SaveCore(abnode, aproc)
-register struct bnode_proc *aproc;
-register struct bnode *abnode; {
+static void SaveCore(register struct bnode *abnode, register struct bnode_proc
+ *aproc)
+{
char tbuffer[256];
struct stat tstat;
register afs_int32 code;
code = renamefile(AFSDIR_SERVER_CORELOG_FILEPATH, tbuffer);
}
-bnode_GetString(abnode, abuffer, alen)
-register struct bnode *abnode;
-register char *abuffer;
-register afs_int32 alen;{
+int bnode_GetString(register struct bnode *abnode, register char *abuffer,
+register afs_int32 alen)
+{
return BOP_GETSTRING(abnode, abuffer, alen);
}
-bnode_GetParm(abnode, aindex, abuffer, alen)
-register struct bnode *abnode;
-register afs_int32 aindex;
-register char *abuffer;
-afs_int32 alen; {
+int bnode_GetParm(register struct bnode *abnode, register afs_int32 aindex,
+ register char *abuffer, afs_int32 alen)
+{
return BOP_GETPARM(abnode, aindex, abuffer, alen);
}
-bnode_GetStat(abnode, astatus)
-register struct bnode *abnode;
-register afs_int32 *astatus; {
+int bnode_GetStat(register struct bnode *abnode, register afs_int32 *astatus)
+{
return BOP_GETSTAT(abnode, astatus);
}
-bnode_RestartP(abnode)
-register struct bnode *abnode; {
+int bnode_RestartP(register struct bnode *abnode)
+{
return BOP_RESTARTP(abnode);
}
-static bnode_Check(abnode)
-register struct bnode *abnode; {
+static int bnode_Check(register struct bnode *abnode)
+{
if (abnode->flags & BNODE_WAIT) {
abnode->flags &= ~BNODE_WAIT;
LWP_NoYieldSignal(abnode);
}
/* tell if an instance has a core file */
-bnode_HasCore(abnode)
-register struct bnode *abnode; {
+int bnode_HasCore(register struct bnode *abnode)
+{
return BOP_HASCORE(abnode);
}
/* wait for all bnodes to stabilize */
-bnode_WaitAll() {
+int bnode_WaitAll() {
register struct bnode *tb;
register afs_int32 code;
afs_int32 stat;
}
/* wait until bnode status is correct */
-bnode_WaitStatus(abnode, astatus)
-int astatus;
-register struct bnode *abnode; {
+int bnode_WaitStatus(register struct bnode *abnode, int astatus)
+{
register afs_int32 code;
afs_int32 stat;
}
}
-bnode_SetStat(abnode, agoal)
-register struct bnode *abnode;
-register int agoal; {
+int bnode_SetStat(register struct bnode *abnode, register int agoal)
+{
abnode->goal = agoal;
bnode_Check(abnode);
BOP_SETSTAT(abnode, agoal);
return 0;
}
-bnode_SetGoal(abnode, agoal)
-register struct bnode *abnode;
-register int agoal; {
+int bnode_SetGoal(register struct bnode *abnode, register int agoal)
+{
abnode->goal = agoal;
bnode_Check(abnode);
return 0;
}
-bnode_SetFileGoal(abnode, agoal)
-register struct bnode *abnode;
-register int agoal; {
+int bnode_SetFileGoal(register struct bnode *abnode, register int agoal)
+{
if (abnode->fileGoal == agoal) return 0; /* already done */
abnode->fileGoal = agoal;
WriteBozoFile(0);
}
/* apply a function to all bnodes in the system */
-int bnode_ApplyInstance(aproc, arock)
-int (*aproc)();
-char *arock; {
+int bnode_ApplyInstance(int (*aproc)(), char *arock)
+{
register struct bnode *tb, *nb;
register afs_int32 code;
return 0;
}
-struct bnode *bnode_FindInstance (aname)
-register char *aname; {
+struct bnode *bnode_FindInstance(register char *aname)
+{
register struct bnode *tb;
for(tb=allBnodes;tb;tb=tb->next) {
if (!strcmp(tb->name, aname)) return tb;
}
- return (struct bnode *) 0;
+ return NULL;
}
-static struct bnode_type *FindType(aname)
-register char *aname; {
+static struct bnode_type *FindType(register char *aname)
+{
register struct bnode_type *tt;
for(tt=allTypes;tt;tt=tt->next) {
return (struct bnode_type *) 0;
}
-bnode_Register(atype, aprocs, anparms)
-char *atype;
-int anparms; /* number of parms to create */
-struct bnode_ops *aprocs; {
+int bnode_Register(char *atype, struct bnode_ops *aprocs, int anparms)
+{
register struct bnode_type *tt;
for(tt=allTypes;tt;tt=tt->next) {
return 0;
}
-afs_int32 bnode_Create(atype, ainstance, abp, ap1, ap2, ap3, ap4, ap5, notifier,fileGoal)
-char *atype;
-char *ainstance;
-struct bnode **abp;
-char *ap1, *ap2, *ap3, *ap4, *ap5, *notifier;
-int fileGoal;{
+afs_int32 bnode_Create(char *atype, char *ainstance, struct bnode **abp,
+ char *ap1, char *ap2, char *ap3, char *ap4,
+ char *ap5, char *notifier, int fileGoal)
+{
struct bnode_type *type;
struct bnode *tb;
char *notifierpath = NULL;
return 0;
}
-int bnode_DeleteName(ainstance)
-char *ainstance; {
+int bnode_DeleteName(char *ainstance)
+{
register struct bnode *tb;
tb = bnode_FindInstance(ainstance);
return bnode_Delete(tb);
}
-bnode_Hold(abnode)
-register struct bnode *abnode; {
+int bnode_Hold(register struct bnode *abnode)
+{
abnode->refCount++;
return 0;
}
-bnode_Release(abnode)
-register struct bnode *abnode; {
+int bnode_Release(register struct bnode *abnode)
+{
abnode->refCount--;
if (abnode->refCount == 0 && abnode->flags & BNODE_DELETE) {
abnode->flags &= ~BNODE_DELETE; /* we're going for it */
return 0;
}
-int bnode_Delete(abnode)
-register struct bnode *abnode; {
+int bnode_Delete(register struct bnode *abnode)
+{
register afs_int32 code;
register struct bnode **lb, *ub;
afs_int32 temp;
}
/* function to tell if there's a timeout coming up */
-int bnode_PendingTimeout(abnode)
-register struct bnode *abnode; {
+int bnode_PendingTimeout(register struct bnode *abnode)
+{
return (abnode->flags & BNODE_NEEDTIMEOUT);
}
/* function called to set / clear periodic bnode wakeup times */
-int bnode_SetTimeout(abnode, atimeout)
-register struct bnode *abnode;
-afs_int32 atimeout; {
+int bnode_SetTimeout(register struct bnode *abnode, afs_int32 atimeout)
+{
if (atimeout != 0) {
abnode->nextTimeout = FT_ApproxTime() + atimeout;
abnode->flags |= BNODE_NEEDTIMEOUT;
}
/* used by new bnode creation code to format bnode header */
-int bnode_InitBnode (abnode, abnodeops, aname)
-register struct bnode *abnode;
-char *aname;
-struct bnode_ops *abnodeops; {
+int bnode_InitBnode (register struct bnode *abnode,
+ struct bnode_ops *abnodeops, char *aname)
+{
struct bnode **lb, *nb;
/* format the bnode properly */
memset(abnode, 0, sizeof(struct bnode));
abnode->ops = abnodeops;
abnode->name = (char *) malloc(strlen(aname)+1);
+ if (!abnode->name)
+ return ENOMEM;
strcpy(abnode->name, aname);
abnode->flags = BNODE_ACTIVE;
abnode->fileGoal = BSTAT_NORMAL;
RememberProcName(tp);
tb->errorSignal = 0;
}
+ if (tp->coreName)
+ bozo_Log("%s:%s exited with code %d\n",
+ tb->name, tp->coreName, tp->lastExit);
+ else
+ bozo_Log("%s exited with code %d\n",
+ tb->name, tp->lastExit);
}
else {
/* Signal occurred, perhaps spurious due to shutdown request.
tb->lastErrorExit = FT_ApproxTime();
RememberProcName(tp);
}
+ if (tp->coreName)
+ bozo_Log("%s:%s exited on signal %d%s\n",
+ tb->name, tp->coreName, tp->lastSignal,
+ WCOREDUMP(status) ? " (core dumped)" : "");
+ else
+ bozo_Log("%s exited on signal %d%s\n",
+ tb->name, tp->lastSignal,
+ WCOREDUMP(status) ? " (core dumped)" : "");
SaveCore(tb, tp);
}
tb->lastAnyExit = FT_ApproxTime();
}
-#ifdef notdef
-sigcatch()
-{
- signal(SIGPIPE, SIG_IGN);
- bozo_Log("Notifier aborted prematurely");
- exit(0);
-}
-#endif
-
-
-
-hdl_notifier(tp)
- struct bnode_proc *tp;
+int hdl_notifier(struct bnode_proc *tp)
{
#ifndef AFS_NT40_ENV /* NT notifier callout not yet implemented */
int code, pid, status;
}
-static afs_int32 SendNotifierData(fd, tp)
- register int fd;
- register struct bnode_proc *tp;
+static afs_int32 SendNotifierData(register int fd,
+ register struct bnode_proc *tp)
{
register struct bnode *tb = tp->bnode;
char buffer[1000], *bufp = buffer, *buf1;
/* Called by IOMGR at low priority on IOMGR's stack shortly after a SIGCHLD
* occurs. Wakes up bproc do redo things */
-bnode_SoftInt(int asignal)
+int bnode_SoftInt(int asignal)
{
IOMGR_Cancel(bproc_pid);
return 0;
/* Called at signal interrupt level; queues function to be called
* when IOMGR runs again.
*/
-void
-bnode_Int(int asignal)
+void bnode_Int(int asignal)
{
extern void bozo_ShutdownAndExit();
}
/* free token list returned by parseLine */
-bnode_FreeTokens(alist)
- register struct bnode_token *alist; {
+int bnode_FreeTokens(register struct bnode_token *alist)
+{
register struct bnode_token *nlist;
for(; alist; alist = nlist) {
nlist = alist->next;
return 0;
}
-static space(x)
-int x; {
+static int space(int x)
+{
if (x == 0 || x == ' ' || x == '\t' || x== '\n') return 1;
else return 0;
}
-bnode_ParseLine(aline, alist)
- char *aline;
- struct bnode_token **alist; {
+int bnode_ParseLine(char *aline, struct bnode_token **alist)
+{
char tbuffer[256];
register char *tptr;
int inToken;
}
#define MAXVARGS 128
-int bnode_NewProc(abnode, aexecString, coreName, aproc)
-struct bnode_proc **aproc;
-char *coreName;
-struct bnode *abnode;
-char *aexecString; {
+int bnode_NewProc(struct bnode *abnode, char *aexecString, char *coreName,
+ struct bnode_proc **aproc)
+{
struct bnode_token *tlist, *tt;
afs_int32 code;
struct bnode_proc *tp;
for (tt = tlist, i = 0; i < (MAXVARGS - 1) && tt; tt = tt->next, i++) {
argv[i] = tt->key;
}
- argv[i] = (char *) 0; /* null-terminated */
+ argv[i] = NULL; /* null-terminated */
cpid = spawnprocve(argv[0], argv, environ, -1);
osi_audit(BOSSpawnProcEvent, 0, AUD_STR, aexecString, AUD_END );
return 0;
}
-int bnode_StopProc(aproc, asignal)
-register struct bnode_proc *aproc;
-int asignal; {
+int bnode_StopProc(register struct bnode_proc *aproc, int asignal)
+{
register int code;
if (!(aproc->flags & BPROC_STARTED) || (aproc->flags & BPROC_EXITED))
return BZNOTACTIVE;
- osi_audit( BOSStopProcEvent, 0, AUD_STR, (aproc ? aproc->comLine : (char *)0), AUD_END );
+ osi_audit( BOSStopProcEvent, 0, AUD_STR, (aproc ? aproc->comLine : NULL), AUD_END );
code = kill(aproc->pid, asignal);
bnode_Check(aproc->bnode);
return code;
}
-int bnode_Deactivate(abnode)
-register struct bnode *abnode; {
+int bnode_Deactivate(register struct bnode *abnode)
+{
register struct bnode **pb, *tb;
struct bnode *nb;
if (!(abnode->flags & BNODE_ACTIVE)) return BZNOTACTIVE;
return BZNOENT;
}
-static int DeleteProc(abproc)
-register struct bnode_proc *abproc; {
+static int DeleteProc(register struct bnode_proc *abproc)
+{
register struct bnode_proc **pb, *tb;
struct bnode_proc *nb;