X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=support%2Fnfs%2Fcacheio.c;h=9d271cd4733d77328a6f2b3e5ec8a80b5da8a73b;hb=12e990f4b07172c693203ffd1e12d0518cacb9e6;hp=3e868d8843e9c9153be7ee595eec4517ec5cd5b4;hpb=940c7c304d4a43c00c27529cdddc7c87db6eef87;p=nfs-utils.git diff --git a/support/nfs/cacheio.c b/support/nfs/cacheio.c index 3e868d8..9d271cd 100644 --- a/support/nfs/cacheio.c +++ b/support/nfs/cacheio.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -109,10 +110,21 @@ void qword_printint(FILE *f, int num) fprintf(f, "%d ", num); } -void qword_eol(FILE *f) +int qword_eol(FILE *f) { + int err; + fprintf(f,"\n"); - fflush(f); + err = fflush(f); + /* + * We must send one line (and one line only) in a single write + * call. In case of a write error, libc may accumulate the + * unwritten data and try to write it again later, resulting in a + * multi-line write. So we must explicitly ask it to throw away + * any such cached data: + */ + __fpurge(f); + return fflush(f); } @@ -247,20 +259,24 @@ cache_flush(int force) int c; char stime[20]; char path[200]; + time_t now; /* Note: the order of these caches is important. - * The need to be flushed in dependancy order. So + * They need to be flushed in dependancy order. So * a cache that references items in another cache, * as nfsd.fh entries reference items in nfsd.export, * must be flushed before the cache that it references. */ static char *cachelist[] = { "auth.unix.ip", + "auth.unix.gid", "nfsd.fh", "nfsd.export", NULL }; + now = time(0); if (force || - stat(_PATH_ETAB, &stb) != 0) + stat(_PATH_ETAB, &stb) != 0 || + stb.st_mtime > now) stb.st_mtime = time(0); sprintf(stime, "%ld\n", stb.st_mtime);