mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0023260: Regression: Instability in parallel incmesh on Linux.
Added protection to the function which may have data race (according to the valgrind report). Added protection to the BRepMesh_FastDiscretFace::RestoreStructureFromTriangulation function Slight reordering to optimize use of mutex (lock once) Now Standard_Mutex::SentryNested are created as named object. Map inside TopTools_MutexForShapeProvider now store Handle_TopoDS_TShape as a key instead of TopoDS_Shape
This commit is contained in:
@@ -84,7 +84,8 @@ is
|
||||
theSurf : HSurface from BRepAdaptor;
|
||||
theTrigu : Triangulation from Poly;
|
||||
theDefEdge : Real from Standard;
|
||||
theLoc : Location from TopLoc)
|
||||
theLoc : Location from TopLoc;
|
||||
theMutexProvider: MutexForShapeProvider from TopTools)
|
||||
returns Boolean from Standard is protected;
|
||||
|
||||
|
||||
|
@@ -57,6 +57,8 @@
|
||||
|
||||
#define UVDEFLECTION 1.e-05
|
||||
|
||||
static Standard_Mutex DummyMutex;
|
||||
|
||||
static Standard_Real FUN_CalcAverageDUV(TColStd_Array1OfReal& P, const Standard_Integer PLen)
|
||||
{
|
||||
Standard_Integer i, j, n = 0;
|
||||
@@ -173,8 +175,7 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face& theFace
|
||||
const TopoDS_Edge& edge = TopoDS::Edge(ex.Value());
|
||||
if(edge.IsNull())
|
||||
continue;
|
||||
|
||||
RestoreStructureFromTriangulation(edge, face, gFace, aFaceTrigu, theMapDefle(edge), loc);
|
||||
RestoreStructureFromTriangulation(edge, face, gFace, aFaceTrigu, theMapDefle(edge), loc, theMutexProvider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,22 +350,28 @@ Standard_Boolean BRepMesh_FastDiscretFace::RestoreStructureFromTriangulation
|
||||
const Handle(BRepAdaptor_HSurface)& theSurf,
|
||||
const Handle(Poly_Triangulation)& theTrigu,
|
||||
const Standard_Real theDefEdge,
|
||||
const TopLoc_Location& theLoc)
|
||||
const TopLoc_Location& theLoc,
|
||||
const TopTools_MutexForShapeProvider& theMutexProvider)
|
||||
{
|
||||
// oan: changes for right restoring of triangulation data from face & edges
|
||||
Handle(Poly_PolygonOnTriangulation) Poly;
|
||||
Poly = BRep_Tool::PolygonOnTriangulation(theEdge, theTrigu, theLoc);
|
||||
|
||||
if (Poly.IsNull() || !Poly->HasParameters())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// 2d vertex indices
|
||||
TopAbs_Orientation orEdge = theEdge.Orientation();
|
||||
// Get end points on 2d curve
|
||||
gp_Pnt2d uvFirst, uvLast;
|
||||
BRep_Tool::UVPoints(theEdge, theFace, uvFirst, uvLast);
|
||||
// oan: changes for right restoring of triangulation data from face & edges
|
||||
Handle(Poly_PolygonOnTriangulation) Poly;
|
||||
|
||||
{
|
||||
// lock mutex during querying data from edge curves to prevent parallel change of the same data
|
||||
Standard_Mutex* aMutex = theMutexProvider.GetMutex(theEdge);
|
||||
Standard_Mutex::SentryNested aSentry(aMutex == NULL ? DummyMutex : *aMutex,
|
||||
aMutex != NULL);
|
||||
|
||||
Poly = BRep_Tool::PolygonOnTriangulation(theEdge, theTrigu, theLoc);
|
||||
if (Poly.IsNull() || !Poly->HasParameters())
|
||||
return Standard_False;
|
||||
|
||||
BRep_Tool::UVPoints(theEdge, theFace, uvFirst, uvLast);
|
||||
}
|
||||
|
||||
// Get vertices
|
||||
TopoDS_Vertex pBegin, pEnd;
|
||||
@@ -1523,8 +1530,6 @@ Standard_Real BRepMesh_FastDiscretFace::Control(const Handle(BRepAdaptor_HSurfac
|
||||
return Sqrt(maxdef);
|
||||
}
|
||||
|
||||
static Standard_Mutex DummyMutex;
|
||||
|
||||
//=======================================================================
|
||||
//function : AddInShape
|
||||
//purpose :
|
||||
@@ -1631,7 +1636,7 @@ void BRepMesh_FastDiscretFace::AddInShape(const TopoDS_Face& theFace,
|
||||
|
||||
// lock mutex to prevent parallel change of the same data
|
||||
Standard_Mutex* aMutex = theMutexProvider.GetMutex(It.Key());
|
||||
Standard_Mutex::SentryNested (aMutex == NULL ? DummyMutex : *aMutex,
|
||||
Standard_Mutex::SentryNested aSentry(aMutex == NULL ? DummyMutex : *aMutex,
|
||||
aMutex != NULL);
|
||||
|
||||
if ( NOD1 == NOD2 ) {
|
||||
|
Reference in New Issue
Block a user