Remove race condition under SMP.

Noted by:	Denis Kalinin <denis@mail.rbc.ru>
This commit is contained in:
Boris Popov 1999-11-21 16:35:29 +00:00
parent 93d6b9b66d
commit 4a22b7e60e
2 changed files with 16 additions and 4 deletions

View File

@ -262,10 +262,16 @@ nwfs_close(ap)
simple_unlock(&vp->v_interlock);
return 0;
}
simple_unlock(&vp->v_interlock);
error = nwfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1);
if (--np->opened == 0) {
error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh, ap->a_p,ap->a_cred);
simple_lock(&vp->v_interlock);
if (np->opened == 0) {
simple_unlock(&vp->v_interlock);
return 0;
}
if (--np->opened == 0)
error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh,
ap->a_p, ap->a_cred);
simple_unlock(&vp->v_interlock);
np->n_atime = 0;
return (error);

View File

@ -262,10 +262,16 @@ nwfs_close(ap)
simple_unlock(&vp->v_interlock);
return 0;
}
simple_unlock(&vp->v_interlock);
error = nwfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1);
if (--np->opened == 0) {
error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh, ap->a_p,ap->a_cred);
simple_lock(&vp->v_interlock);
if (np->opened == 0) {
simple_unlock(&vp->v_interlock);
return 0;
}
if (--np->opened == 0)
error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh,
ap->a_p, ap->a_cred);
simple_unlock(&vp->v_interlock);
np->n_atime = 0;
return (error);