Skip to content

Commit

Permalink
fixed deadlock in SaveChain()
Browse files Browse the repository at this point in the history
'2013.01.28 - fixed deadlock in SaveChain in case of isolated road cycle
  • Loading branch information
OverQuantum committed Jan 28, 2013
1 parent 643162c commit 8fd8be5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sources/mp_extsimp.bas
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Attribute VB_Name = "mp_extsimp1"
'2012.11.15-20 - adding explaining comments, small fixes
'2012.11.20 - added license and references
'2013.01.08 - added CollapseShortEdges (fix "too close nodes")
'2013.01.28 - fixed deadlock in SaveChain in case of isolated road cycle

'TODO:
'*? dump problems of OSM data (1: too long links, 2: ?)
Expand Down Expand Up @@ -893,6 +894,7 @@ Public Sub SaveChain(edge1 As Long)
Dim refedge As edge
Dim ChainEnd As Long
Dim NextChainEdge As Long
Dim startnode As Long

Dim k1 As Long, k2 As Long
Dim typ As Long
Expand All @@ -912,6 +914,8 @@ Public Sub SaveChain(edge1 As Long)
i = Edges(edge1).node1 'start node
j = Edges(edge1).node2

startnode = j

If Nodes(i).Edges <> 2 Then
'i is end of chain
ChainNum = 0
Expand All @@ -934,7 +938,7 @@ Public Sub SaveChain(edge1 As Long)

lGoNext:
k = GoByChain(i, j) 'go by chain
If Nodes(k).Edges = 2 Then j = i: i = k: GoTo lGoNext 'if still 2 edges - proceed
If Nodes(k).Edges = 2 And k <> startnode Then j = i: i = k: GoTo lGoNext 'if still 2 edges and we have not found loop - proceed

' *-----*-----*-----*---...
' k i j
Expand All @@ -949,6 +953,7 @@ lGoNext:
ChainNum = 0
Call AddChain(k)
Call AddChain(i)
startnode = k

'keep info about first edge in chain
refedge = Edges(GoByChain_lastedge)
Expand Down Expand Up @@ -976,7 +981,7 @@ lGoNext2:

Call AddChain(k)

If Nodes(k).Edges = 2 Then
If Nodes(k).Edges = 2 And k <> startnode Then
'still 2 edges - still chain
j = i
i = k
Expand Down

0 comments on commit 8fd8be5

Please sign in to comment.