fix state overwrite bug
I have needed to excercise a lot of care in threading st through, and I got it wrong here. Probably using a state monad would be a good idea.
This commit is contained in:
		
					parent
					
						
							
								76fa43e882
							
						
					
				
			
			
				commit
				
					
						7cc4312695
					
				
			
		
					 2 changed files with 6 additions and 42 deletions
				
			
		
							
								
								
									
										12
									
								
								Annex/Sim.hs
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								Annex/Sim.hs
									
										
									
									
									
								
							| 
						 | 
					@ -941,19 +941,19 @@ updateSimRepos :: SimState SimRepo -> IO (SimState SimRepo)
 | 
				
			||||||
updateSimRepos st = updateSimRepoStates st >>= initNewSimRepos
 | 
					updateSimRepos st = updateSimRepoStates st >>= initNewSimRepos
 | 
				
			||||||
 | 
					
 | 
				
			||||||
updateSimRepoStates :: SimState SimRepo -> IO (SimState SimRepo)
 | 
					updateSimRepoStates :: SimState SimRepo -> IO (SimState SimRepo)
 | 
				
			||||||
updateSimRepoStates st = go st (M.toList $ simRepoState st)
 | 
					updateSimRepoStates inst = go inst (M.toList $ simRepoState inst)
 | 
				
			||||||
  where
 | 
					  where
 | 
				
			||||||
	go st' [] = return st'
 | 
						go st [] = return st
 | 
				
			||||||
	go st' ((u, rst):rest) = case simRepo rst of
 | 
						go st ((u, rst):rest) = case simRepo rst of
 | 
				
			||||||
		Just sr -> do
 | 
							Just sr -> do
 | 
				
			||||||
			sr' <- updateSimRepoState st sr
 | 
								sr' <- updateSimRepoState st sr
 | 
				
			||||||
			let rst' = rst { simRepo = Just sr' }
 | 
								let rst' = rst { simRepo = Just sr' }
 | 
				
			||||||
			let st'' = st
 | 
								let st' = st
 | 
				
			||||||
				{ simRepoState = M.insert u rst'
 | 
									{ simRepoState = M.insert u rst'
 | 
				
			||||||
					(simRepoState st)
 | 
										(simRepoState st)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			go st'' rest
 | 
								go st' rest
 | 
				
			||||||
		Nothing -> go st' rest
 | 
							Nothing -> go st rest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
initNewSimRepos :: SimState SimRepo -> IO (SimState SimRepo)
 | 
					initNewSimRepos :: SimState SimRepo -> IO (SimState SimRepo)
 | 
				
			||||||
initNewSimRepos = \st -> go st (M.toList $ simRepoState st)
 | 
					initNewSimRepos = \st -> go st (M.toList $ simRepoState st)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,42 +30,6 @@ Planned schedule of work:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* Currently working in [[todo/proving_preferred_content_behavior]]
 | 
					* Currently working in [[todo/proving_preferred_content_behavior]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* sim: updateSimRepoState turns out to call preferredContentSet repeatedly
 | 
					 | 
				
			||||||
  and also preferred content changes made part way through the sim 
 | 
					 | 
				
			||||||
  seem to not take effect. Test case is this, which should not end 
 | 
					 | 
				
			||||||
  by getting a file into bar that it no longer wants, and which was just
 | 
					 | 
				
			||||||
  dropped.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Note that this test case does not behave this way if the final
 | 
					 | 
				
			||||||
  step is run in a separate git-annex sim command. It's only when
 | 
					 | 
				
			||||||
  it's run by git-annex sim start that it does.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
seed 5338836154135478106
 | 
					 | 
				
			||||||
init foo
 | 
					 | 
				
			||||||
init bar
 | 
					 | 
				
			||||||
connect foo <-> bar
 | 
					 | 
				
			||||||
addmulti 10 testfile 100.0kB 10.0MB foo
 | 
					 | 
				
			||||||
wanted bar anything
 | 
					 | 
				
			||||||
wanted foo anything
 | 
					 | 
				
			||||||
step 20
 | 
					 | 
				
			||||||
present bar 8testfile
 | 
					 | 
				
			||||||
present bar 6testfile
 | 
					 | 
				
			||||||
present bar 4testfile
 | 
					 | 
				
			||||||
present bar 5testfile
 | 
					 | 
				
			||||||
present bar 7testfile
 | 
					 | 
				
			||||||
present bar 1testfile
 | 
					 | 
				
			||||||
present bar 9testfile
 | 
					 | 
				
			||||||
present bar 2testfile
 | 
					 | 
				
			||||||
present bar 10testfile
 | 
					 | 
				
			||||||
present bar 3testfile
 | 
					 | 
				
			||||||
wanted bar nothing
 | 
					 | 
				
			||||||
step 5
 | 
					 | 
				
			||||||
notpresent bar 6testfile
 | 
					 | 
				
			||||||
notpresent bar 1testfile
 | 
					 | 
				
			||||||
notpresent bar 8testfile
 | 
					 | 
				
			||||||
notpresent bar 10testfile
 | 
					 | 
				
			||||||
present bar 1testfile
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* sim: Can a cluster using size balanced preferred content be simulated?
 | 
					* sim: Can a cluster using size balanced preferred content be simulated?
 | 
				
			||||||
  May need the sim to get the concept of a cluster gateway, since the
 | 
					  May need the sim to get the concept of a cluster gateway, since the
 | 
				
			||||||
  gateway is what picks amoung the nodes on the basis of size. On the other
 | 
					  gateway is what picks amoung the nodes on the basis of size. On the other
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue