Fix lock leak in purely hypothetical case of TCP connection without SVC_ACK

method.  This change should be NOP now, but it is better to be future safe.

Reported by:	rmacklem
This commit is contained in:
Alexander Motin 2014-01-14 20:18:38 +00:00
parent f3f38455ea
commit 6103bae6ae
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=260648
3 changed files with 13 additions and 11 deletions

View File

@ -220,7 +220,7 @@ void nfsrvd_dorpc(struct nfsrv_descript *, int, NFSPROC_T *);
void nfsrvd_initcache(void);
int nfsrvd_getcache(struct nfsrv_descript *);
struct nfsrvcache *nfsrvd_updatecache(struct nfsrv_descript *);
void nfsrvd_sentcache(struct nfsrvcache *, uint32_t);
void nfsrvd_sentcache(struct nfsrvcache *, int, uint32_t);
void nfsrvd_cleancache(void);
void nfsrvd_refcache(struct nfsrvcache *);
void nfsrvd_derefcache(struct nfsrvcache *);

View File

@ -576,18 +576,20 @@ nfsrvd_delcache(struct nfsrvcache *rp)
* the pointer returned by nfsrvd_updatecache().
*/
APPLESTATIC void
nfsrvd_sentcache(struct nfsrvcache *rp, uint32_t seq)
nfsrvd_sentcache(struct nfsrvcache *rp, int have_seq, uint32_t seq)
{
struct nfsrchash_bucket *hbp;
KASSERT(rp->rc_flag & RC_LOCKED, ("nfsrvd_sentcache not locked"));
hbp = NFSRCAHASH(rp->rc_sockref);
mtx_lock(&hbp->mtx);
rp->rc_tcpseq = seq;
if (rp->rc_acked != RC_NO_ACK)
LIST_INSERT_HEAD(&hbp->tbl, rp, rc_ahash);
rp->rc_acked = RC_NO_ACK;
mtx_unlock(&hbp->mtx);
if (have_seq) {
hbp = NFSRCAHASH(rp->rc_sockref);
mtx_lock(&hbp->mtx);
rp->rc_tcpseq = seq;
if (rp->rc_acked != RC_NO_ACK)
LIST_INSERT_HEAD(&hbp->tbl, rp, rc_ahash);
rp->rc_acked = RC_NO_ACK;
mtx_unlock(&hbp->mtx);
}
nfsrc_unlock(rp);
}

View File

@ -287,8 +287,8 @@ nfssvc_program(struct svc_req *rqst, SVCXPRT *xprt)
svcerr_systemerr(rqst);
}
if (rp != NULL) {
if (rqst->rq_reply_seq != 0 || SVC_ACK(xprt, NULL))
nfsrvd_sentcache(rp, rqst->rq_reply_seq);
nfsrvd_sentcache(rp, (rqst->rq_reply_seq != 0 ||
SVC_ACK(xprt, NULL)), rqst->rq_reply_seq);
}
svc_freereq(rqst);