Revision 1d4febbd

b/src/Ganeti/WConfd/Monad.hs
80 80
  -- daemon should go here;
81 81
  -- all IDs of threads that do asynchronous work should probably also go here
82 82
  , dhSaveConfigWorker :: AsyncWorker ()
83
  , dhSaveLocksWorker :: AsyncWorker ()
83 84
  }
84 85

  
85 86
mkDaemonHandle :: FilePath
......
88 89
               -> (IO ConfigState -> ResultG (AsyncWorker ()))
89 90
                  -- ^ A function that creates a worker that asynchronously
90 91
                  -- saves the configuration to the master file.
92
               -> (IO GanetiLockAllocation -> ResultG (AsyncWorker ()))
93
                  -- ^ A function that creates a worker that asynchronously
94
                  -- saves the lock allocation state.
91 95
               -> ResultG DaemonHandle
92
mkDaemonHandle cpath cstat lstat saveWorkerFn = do
96
mkDaemonHandle cpath cstat lstat saveConfigWorkerFn saveLockWorkerFn = do
93 97
  ds <- newIORef $ DaemonState cstat lstat
94
  saveWorker <- saveWorkerFn $ dsConfigState `liftM` readIORef ds
95
  return $ DaemonHandle ds cpath saveWorker
98
  saveConfigWorker <- saveConfigWorkerFn $ dsConfigState `liftM` readIORef ds
99
  saveLockWorker <- saveLockWorkerFn $ dsLockAllocation `liftM` readIORef ds
100
  return $ DaemonHandle ds cpath saveConfigWorker saveLockWorker
96 101

  
97 102
-- * The monad and its instances
98 103

  
......
173 178
  dh <- lift . WConfdMonadInt $ ask
174 179
  let mf ds = let (la', r) = f (dsLockAllocation ds)
175 180
              in (ds { dsLockAllocation = la' }, r)
176
  atomicModifyIORef (dhDaemonState dh) mf
177
  -- TODO: Trigger the async. lock saving worker
181
  r <- atomicModifyIORef (dhDaemonState dh) mf
182
  logDebug "Triggering lock state write"
183
  liftBase . triggerAndWait . dhSaveLocksWorker $ dh
184
  logDebug "Lock write finished"
185
  return r
178 186

  
179 187
-- | Atomically modifies the lock allocation state in WConfdMonad, not
180 188
-- producing any result
b/src/Ganeti/WConfd/Server.hs
85 85
                   (mkConfigState cdata)
86 86
                   lock
87 87
                   (saveConfigAsyncTask conf_file cstat)
88
                   (writeLocksAsyncTask lock_file)
88 89
  dh <- withError (strMsg . ("Initialization of the daemon failed" ++) . show)
89 90
                  dhOpt
90 91

  

Also available in: Unified diff