From 2c2433be50362cf58ded7d42e6705d962975ee6b Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Thu, 29 Nov 2007 21:10:45 +0000 Subject: Improve cosmetically some debug messages and comments. Be a little more conservative about when to flush the cached file. --- plpnfsd/main.cc | 28 +++++++++++++++------------- plpnfsd/mp_pfs_ops.c | 10 +++++----- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/plpnfsd/main.cc b/plpnfsd/main.cc index a2ad9dd..271319b 100644 --- a/plpnfsd/main.cc +++ b/plpnfsd/main.cc @@ -231,6 +231,17 @@ long rfsv_isalive() { return (a->getStatus() == rfsv::E_PSI_GEN_NONE); } +long rfsv_closecached() { + if (!a) + return -1; + if (!a_filename) + return 0; + a->fclose(a_handle); + free(a_filename); + a_filename = NULL; + return 0; +} + long rfsv_dir(const char *file, dentry **e) { PlpDir entries; dentry *tmp; @@ -264,6 +275,7 @@ long rfsv_dircount(const char *file, u_int32_t *count) { long rfsv_rmdir(const char *name) { if (!a) return -1; + rfsv_closecached(); /* Just in case we're caching stuff in this dir */ return a->rmdir(name); } @@ -273,17 +285,6 @@ long rfsv_mkdir(const char *file) { return a->mkdir(file); } -long rfsv_closecached() { - if (!a) - return -1; - if (!a_filename) - return 0; - a->fclose(a_handle); - free(a_filename); - a_filename = NULL; - return 0; -} - long rfsv_remove(const char *file) { if (!a) return -1; @@ -438,8 +439,9 @@ long rfsv_statdev(char letter) { long rfsv_rename(const char *oldname, const char *newname) { if (!a) return -1; - if (a_filename && (!strcmp(a_filename, oldname) || !strcmp(a_filename, newname))) - rfsv_closecached(); + /* We could be renaming a directory containing the cached item, so + always flush */ + rfsv_closecached(); return a->rename(oldname, newname); } diff --git a/plpnfsd/mp_pfs_ops.c b/plpnfsd/mp_pfs_ops.c index f9057d4..c541745 100644 --- a/plpnfsd/mp_pfs_ops.c +++ b/plpnfsd/mp_pfs_ops.c @@ -675,7 +675,7 @@ nfsproc_getattr_2(struct nfs_fh *fh) int builtin = 0; int l; - debuglog("getattr:'%s',%d\n", inode->name, inode->inode); + debuglog("getattr: '%s',%d\n", inode->name, inode->inode); res.status = NFS_OK; if ((cp = search_cache(attrcache, inode->inode))) { @@ -688,13 +688,13 @@ nfsproc_getattr_2(struct nfs_fh *fh) if (inode->inode == root_fattr.fileid) { /* It's the root inode */ - debuglog("getattr:root inode (%#o)\n", root_fattr.mode); + debuglog("getattr: root inode (%#o)\n", root_fattr.mode); if (query_devices()) /* root inode and proc is always there */ root_fattr.nlink = 3; *fp = root_fattr; } else if (l == 2 && inode->name[1] == ':') { - debuglog("getattr:device\n"); + debuglog("getattr: device\n"); res.status = NO_PSION; if (!query_devices()) { device *dp; @@ -742,7 +742,7 @@ nfsproc_getattr_2(struct nfs_fh *fh) } if (!builtin) { - debuglog("getattr:fileordir\n"); + debuglog("getattr: fileordir\n"); /* It's a normal file/dir */ debuglog("RFSV getattr %s\n", inode->name); if (rfsv_getattr(inode->name, &pattr, &psize, &ptime)) { @@ -1205,7 +1205,7 @@ nfsproc_read_2(struct readargs *ra) } fp = &res.readres_u.reply.attributes; if (!cp) { - // Problem: if an epoc process is enlarging the file, we wont recognize it + // Problem: if an EPOC process is enlarging the file, we won't recognize it debuglog("RFSV getattr %s\n", inode->name); if (builtin) { pattr = bn->attr; -- cgit v1.2.3