improve error handling and logging.
This commit is contained in:
parent
6098e2d456
commit
aeccdbb591
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: scmio.c,v 1.19 2009/10/18 15:23:54 christos Exp $ */
|
||||
/* $NetBSD: scmio.c,v 1.20 2010/10/20 17:05:54 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Carnegie Mellon University
|
||||
@ -542,7 +542,7 @@ readmsg(int msg)
|
||||
(void) readmend();
|
||||
if (goawayreason == NULL)
|
||||
return (SCMEOF);
|
||||
logerr("SCM GOAWAY %s", goawayreason);
|
||||
logerr("SCM GOAWAY for %s %s", remotehost(), goawayreason);
|
||||
return (SCMEOF);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: supcmeat.c,v 1.37 2009/10/17 20:46:03 christos Exp $ */
|
||||
/* $NetBSD: supcmeat.c,v 1.38 2010/10/20 17:05:54 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Carnegie Mellon University
|
||||
@ -1407,20 +1407,24 @@ finishup(int x)
|
||||
}
|
||||
(void) sprintf(fname, FILEWHEN, collname, relsufix);
|
||||
if (establishdir(fname)) {
|
||||
int oerrno = errno;
|
||||
Tfree(&lastT);
|
||||
if (protver < 6)
|
||||
return;
|
||||
done(FDONEUSRERROR, "Couldn't timestamp");
|
||||
done(FDONEUSRERROR, "Couldn't create directory `%s' (%s)",
|
||||
fname, strerror(oerrno));
|
||||
(void) requestend();
|
||||
return;
|
||||
}
|
||||
if (!putwhen(fname, scantime)) {
|
||||
int oerrno = errno;
|
||||
notify("SUP: Can't record current time in %s (%s)\n",
|
||||
fname, strerror(errno));
|
||||
fname, strerror(oerrno));
|
||||
Tfree(&lastT);
|
||||
if (protver < 6)
|
||||
return;
|
||||
done(FDONEUSRERROR, "Couldn't timestamp");
|
||||
done(FDONEUSRERROR, "Couldn't timestamp `%s' (%s)",
|
||||
fname, strerror(oerrno));
|
||||
(void) requestend();
|
||||
return;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: supcmisc.c,v 1.20 2009/10/16 12:41:37 christos Exp $ */
|
||||
/* $NetBSD: supcmisc.c,v 1.21 2010/10/20 17:05:54 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Carnegie Mellon University
|
||||
@ -144,14 +144,17 @@ estabd(char *fname, char *dname)
|
||||
if (strcmp(fpart, ".") == 0) { /* dname is / or . */
|
||||
notify("SUP: Can't create directory %s for %s (Invalid name)\n",
|
||||
dname, fname);
|
||||
errno = EINVAL;
|
||||
return (TRUE);
|
||||
}
|
||||
x = estabd(fname, dpart);
|
||||
if (x)
|
||||
return (TRUE);
|
||||
if (makedir(dname, 0755, &sbuf) < 0) {
|
||||
int oerrno = errno;
|
||||
notify("SUP: Can't create directory %s for %s (%s)\n", dname,
|
||||
fname, strerror(errno));
|
||||
errno = oerrno;
|
||||
return TRUE;
|
||||
}
|
||||
vnotify("SUP Created directory %s for %s\n", dname, fname);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: supfilesrv.c,v 1.43 2009/10/17 20:46:03 christos Exp $ */
|
||||
/* $NetBSD: supfilesrv.c,v 1.44 2010/10/20 17:05:54 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Carnegie Mellon University
|
||||
@ -783,7 +783,7 @@ srvsetup(void)
|
||||
{
|
||||
int x;
|
||||
char *p, *q;
|
||||
char buf[STRINGLENGTH];
|
||||
char buf[STRINGLENGTH], filename[MAXPATHLEN];
|
||||
FILE *f;
|
||||
struct stat sbuf;
|
||||
TREELIST *tl;
|
||||
@ -882,8 +882,8 @@ srvsetup(void)
|
||||
release = estrdup(DEFRELEASE);
|
||||
if (basedir == NULL || *basedir == '\0') {
|
||||
basedir = NULL;
|
||||
(void) sprintf(buf, FILEDIRS, DEFDIR);
|
||||
f = fopen(buf, "r");
|
||||
(void) sprintf(filename, FILEDIRS, DEFDIR);
|
||||
f = fopen(filename, "r");
|
||||
if (f) {
|
||||
while ((p = fgets(buf, STRINGLENGTH, f)) != NULL) {
|
||||
q = strchr(p, '\n');
|
||||
@ -906,9 +906,10 @@ srvsetup(void)
|
||||
}
|
||||
}
|
||||
if (chdir(basedir) < 0)
|
||||
goaway("Can't chdir to base directory %s", basedir);
|
||||
(void) sprintf(buf, FILEPREFIX, collname);
|
||||
f = fopen(buf, "r");
|
||||
goaway("Can't chdir to base directory %s (%s)", basedir,
|
||||
strerror(errno));
|
||||
(void) sprintf(filename, FILEPREFIX, collname);
|
||||
f = fopen(filename, "r");
|
||||
if (f) {
|
||||
while ((p = fgets(buf, STRINGLENGTH, f)) != NULL) {
|
||||
q = strchr(p, '\n');
|
||||
@ -918,8 +919,9 @@ srvsetup(void)
|
||||
continue;
|
||||
prefix = estrdup(p);
|
||||
if (chdir(prefix) < 0)
|
||||
goaway("Can't chdir to %s from base directory %s",
|
||||
prefix, basedir);
|
||||
goaway("%s: Can't chdir to %s from base "
|
||||
"directory %s (%s)", filename, prefix,
|
||||
basedir, strerror(errno));
|
||||
break;
|
||||
}
|
||||
(void) fclose(f);
|
||||
@ -928,7 +930,8 @@ srvsetup(void)
|
||||
if (prefix)
|
||||
(void) chdir(basedir);
|
||||
if (x < 0)
|
||||
goaway("Can't stat base/prefix directory");
|
||||
goaway("Can't stat base/prefix directory (%s)",
|
||||
strerror(errno));
|
||||
if (nchildren >= maxchildren) {
|
||||
setupack = FSETUPBUSY;
|
||||
(void) msgsetupack();
|
||||
@ -1468,15 +1471,15 @@ srvfinishup(time_t starttime)
|
||||
if (donereason == NULL)
|
||||
donereason = estrdup("No reason");
|
||||
if (doneack == FDONESRVERROR || doneack == FDONEUSRERROR)
|
||||
logerr("%s", donereason);
|
||||
logerr("%s: %s", remotehost(), donereason);
|
||||
else if (doneack == FDONEGOAWAY)
|
||||
logerr("GOAWAY: %s", donereason);
|
||||
logerr("GOAWAY: %s: %s", remotehost(), donereason);
|
||||
else if (doneack != FDONESUCCESS)
|
||||
logerr("Reason %d: %s", doneack, donereason);
|
||||
logerr("%s: Reason %d: %s", remotehost(), doneack, donereason);
|
||||
goawayreason = donereason;
|
||||
cdprefix((char *) NULL);
|
||||
if (collname == NULL) {
|
||||
logerr("NULL collection in svrfinishup");
|
||||
logerr("%s: NULL collection in svrfinishup", remotehost());
|
||||
return;
|
||||
}
|
||||
(void) sprintf(lognam, FILELOGFILE, collname);
|
||||
@ -1789,7 +1792,7 @@ goaway(const char *fmt, ...)
|
||||
va_end(ap);
|
||||
goawayreason = estrdup(buf);
|
||||
(void) msggoaway();
|
||||
logerr("%s", buf);
|
||||
logerr("%s: %s", remotehost(), buf);
|
||||
longjmp(sjbuf, TRUE);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user