windows-performance-deadlock-20080308

LICENSE MIT

correct a deadlock when calling HaveCallback
This commit is contained in:
Jeffrey Altman 2008-03-08 23:15:54 +00:00
parent 694202f29e
commit c32f5466f0

View File

@ -103,8 +103,10 @@ void cm_PerformanceAddSCache(cm_scache_t *scp)
statp->fileLength = scp->length; statp->fileLength = scp->length;
statp->fileType = scp->fileType; statp->fileType = scp->fileType;
statp->flags = CM_FIDSTATS_FLAG_HAVE_SCACHE; statp->flags = CM_FIDSTATS_FLAG_HAVE_SCACHE;
lock_ConvertRToW(&scp->rw);
if (cm_HaveCallback(scp)) if (cm_HaveCallback(scp))
statp->flags |= CM_FIDSTATS_FLAG_CALLBACK; statp->flags |= CM_FIDSTATS_FLAG_CALLBACK;
lock_ConvertWToR(&scp->rw);
if (scp->flags & CM_SCACHEFLAG_RO) if (scp->flags & CM_SCACHEFLAG_RO)
statp->flags |= CM_FIDSTATS_FLAG_RO; statp->flags |= CM_FIDSTATS_FLAG_RO;
if (scp->flags & CM_SCACHEFLAG_PURERO) if (scp->flags & CM_SCACHEFLAG_PURERO)
@ -160,7 +162,9 @@ void cm_PerformanceTuningInit(void)
for (scp=cm_data.scacheHashTablep[i]; scp; scp=scp->nextp) { for (scp=cm_data.scacheHashTablep[i]; scp; scp=scp->nextp) {
if (scp->fid.cell == 0) if (scp->fid.cell == 0)
continue; continue;
lock_ReleaseRead(&cm_scacheLock);
cm_PerformanceAddSCache(scp); cm_PerformanceAddSCache(scp);
lock_ObtainRead(&cm_scacheLock);
} }
} }
lock_ReleaseRead(&cm_scacheLock); lock_ReleaseRead(&cm_scacheLock);
@ -296,8 +300,11 @@ void cm_PerformanceTuningCheck(void)
break; break;
} }
} }
if (!statp) if (!statp) {
lock_ReleaseRead(&cm_scacheLock);
cm_PerformanceAddSCache(scp); cm_PerformanceAddSCache(scp);
lock_ObtainRead(&cm_scacheLock);
}
} }
} }
lock_ReleaseRead(&cm_scacheLock); lock_ReleaseRead(&cm_scacheLock);