From: Jeffrey Altman Date: Sun, 18 Nov 2012 02:32:44 +0000 (-0500) Subject: Windows: buf_CleanLocked validate cm_scache_t X-Git-Tag: upstream/1.8.0_pre1^2~1800 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=c99797eadc80efa24972a85d1c37e03393c888ca;p=packages%2Fo%2Fopenafs.git Windows: buf_CleanLocked validate cm_scache_t If the cm_scache_t object is not passed in by the caller ensure that the cm_scache_t has a valid callback. If the cm_scache_t has the CM_SCACHEFLAG_DELETED flag set, clear the dirty flag on the cm_buf_t and do not bother contacting the file server. Change-Id: If85be550b59765f64aadea4e1882af9430cebcb4 Reviewed-on: http://gerrit.openafs.org/8473 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/afsd/cm_buf.c b/src/WINNT/afsd/cm_buf.c index 1b8ccecc7..bed02b045 100644 --- a/src/WINNT/afsd/cm_buf.c +++ b/src/WINNT/afsd/cm_buf.c @@ -816,6 +816,23 @@ afs_uint32 buf_CleanLocked(cm_scache_t *scp, cm_buf_t *bp, cm_req_t *reqp, reqp) == 0) { release_scp = 1; + + lock_ObtainWrite(&scp->rw); + code = cm_SyncOp(scp, NULL, bp->userp ? bp->userp : cm_rootUserp, reqp, 0, + CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS); + if (code == 0) { + cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS); + } + lock_ReleaseWrite(&scp->rw); + } + + if (scp && (scp->flags & CM_SCACHEFLAG_DELETED)) { + _InterlockedAnd(&bp->flags, ~CM_BUF_DIRTY); + _InterlockedOr(&bp->flags, CM_BUF_ERROR); + bp->dirty_length = 0; + bp->error = code; + bp->dataVersion = CM_BUF_VERSION_BAD; + bp->dirtyCounter++; } while ((bp->flags & CM_BUF_DIRTY) == CM_BUF_DIRTY) {