diff --git a/usr.sbin/puffs/mount_psshfs/node.c b/usr.sbin/puffs/mount_psshfs/node.c index 2df3eec1ab13..8924c2f89a06 100644 --- a/usr.sbin/puffs/mount_psshfs/node.c +++ b/usr.sbin/puffs/mount_psshfs/node.c @@ -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 #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 @@ -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); diff --git a/usr.sbin/puffs/mount_psshfs/psshfs.c b/usr.sbin/puffs/mount_psshfs/psshfs.c index 12b5f8548aba..2d9df8d37e86 100644 --- a/usr.sbin/puffs/mount_psshfs/psshfs.c +++ b/usr.sbin/puffs/mount_psshfs/psshfs.c @@ -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 #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 @@ -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; } diff --git a/usr.sbin/puffs/mount_psshfs/psshfs.h b/usr.sbin/puffs/mount_psshfs/psshfs.h index dd812602c28c..0bdd92c959cc 100644 --- a/usr.sbin/puffs/mount_psshfs/psshfs.h +++ b/usr.sbin/puffs/mount_psshfs/psshfs.h @@ -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;