Don't overload "attributes last read" for the symlink cache,

use a separate variable.
This commit is contained in:
pooka 2007-11-11 18:06:35 +00:00
parent 0994f0a98c
commit b0106b7eaf
3 changed files with 22 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: node.c,v 1.43 2007/11/10 18:36:06 pooka Exp $ */
/* $NetBSD: node.c,v 1.44 2007/11/11 18:06:35 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: node.c,v 1.43 2007/11/10 18:36:06 pooka Exp $");
__RCSID("$NetBSD: node.c,v 1.44 2007/11/11 18:06:35 pooka Exp $");
#endif /* !lint */
#include <assert.h>
@ -491,10 +491,22 @@ psshfs_node_readlink(struct puffs_cc *pcc, void *opc,
goto out;
}
/* check if we can use a cached version */
if (psn->attrread && !REFRESHTIMEOUT(pctx, time(NULL) - psn->attrread))
/*
* check if we can use a cached version
*
* XXX: we might end up reading the same link multiple times
* from the server if we get many requests at once, but that's
* quite harmless as this routine is reentrant.
*/
if (psn->symlink && !REFRESHTIMEOUT(pctx, time(NULL) - psn->slread))
goto copy;
if (psn->symlink) {
free(psn->symlink);
psn->symlink = NULL;
psn->slread = 0;
}
psbuf_req_str(pb, SSH_FXP_READLINK, reqid, PNPATH(pn));
GETRESPONSE(pb);
@ -506,11 +518,10 @@ psshfs_node_readlink(struct puffs_cc *pcc, void *opc,
goto out;
}
if (psn->symlink)
free(psn->symlink);
rv = psbuf_get_str(pb, &psn->symlink, NULL);
if (rv)
goto out;
psn->slread = time(NULL);
copy:
*linklen = strlen(psn->symlink);

View File

@ -1,4 +1,4 @@
/* $NetBSD: psshfs.c,v 1.42 2007/11/08 17:49:43 pooka Exp $ */
/* $NetBSD: psshfs.c,v 1.43 2007/11/11 18:06:35 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: psshfs.c,v 1.42 2007/11/08 17:49:43 pooka Exp $");
__RCSID("$NetBSD: psshfs.c,v 1.43 2007/11/11 18:06:35 pooka Exp $");
#endif /* !lint */
#include <sys/types.h>
@ -294,6 +294,7 @@ invalone(struct puffs_usermount *pu, struct puffs_node *pn, void *arg)
psn->attrread = 0;
psn->dentread = 0;
psn->slread = 0;
return NULL;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: psshfs.h,v 1.27 2007/11/10 18:36:06 pooka Exp $ */
/* $NetBSD: psshfs.h,v 1.28 2007/11/11 18:06:36 pooka Exp $ */
/*
* Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved.
@ -125,6 +125,7 @@ struct psshfs_node {
time_t attrread;
char *symlink;
time_t slread;
struct puffs_framebuf *getattr_pb;
char *fhand_r;